This commit is contained in:
Trey t
2023-07-13 22:53:29 -05:00
parent 93b8d674b4
commit d57afc1527
2 changed files with 53 additions and 5 deletions

View File

@@ -54,6 +54,21 @@ extension ExerciseElement {
}
return nil
}
func returnOtherVideoURL(currentURL: URL) -> URL? {
var urlString: String?
if currentURL.absoluteString.lowercased().contains(exercise.nsfwVideoURL.lowercased()) {
urlString = exercise.videoURL
} else {
urlString = exercise.nsfwVideoURL
}
if let urlString = urlString,
let url = URL(string: BaseURLs.currentBaseURL + urlString) {
return url
}
return nil
}
}
struct ExerciseExercise: Codable, Hashable, Identifiable {
@@ -123,4 +138,19 @@ extension ExerciseExercise {
}
return nil
}
func returnOtherVideoURL(currentURL: URL) -> URL? {
var urlString: String?
if currentURL.absoluteString.lowercased().contains(nsfwVideoURL.lowercased()) {
urlString = videoURL
} else {
urlString = nsfwVideoURL
}
if let urlString = urlString,
let url = URL(string: BaseURLs.currentBaseURL + urlString) {
return url
}
return nil
}
}

View File

@@ -41,11 +41,29 @@ struct WorkoutDetailView: View {
.frame(maxWidth: .infinity)
GeometryReader { metrics in
PlayerView(player: $avPlayer)
.frame(width: metrics.size.width * 1, height: metrics.size.height * 1)
.onAppear{
avPlayer.play()
}
ZStack {
PlayerView(player: $avPlayer)
.frame(width: metrics.size.width * 1, height: metrics.size.height * 1)
.onAppear{
avPlayer.play()
}
Button(action: {
if let assetURL = ((avPlayer.currentItem?.asset) as? AVURLAsset)?.url,
let videoURL = bridgeModule.currentExercise?.returnOtherVideoURL(currentURL: assetURL) {
avPlayer = AVPlayer(url: videoURL)
avPlayer.play()
}
}, label: {
Text("Toggle THOT")
.padding()
})
.background(.yellow)
.foregroundColor(.blue)
.cornerRadius(4)
.frame(width: 160, height: 60)
.position(x: metrics.size.width - 80, y: metrics.size.height - 30)
}
}
}