This commit is contained in:
Trey t
2023-07-14 15:29:24 -05:00
parent d57afc1527
commit 593cc496cd
9 changed files with 150 additions and 2991 deletions

View File

@@ -16,7 +16,11 @@ struct ExerciseListView: View {
@State var videoExercise: ExerciseExercise? {
didSet {
if let videoURL = self.videoExercise?.videoURL(thotStyle: thotStyle) {
if let videoURL = VideoURLCreator.videoURL(
thotStyle: thotStyle,
defaultVideoURLStr: self.videoExercise?.videoURL,
exerciseName: self.videoExercise?.name,
workout: bridgeModule.currentWorkout) {
avPlayer = AVPlayer(url: videoURL)
avPlayer.play()
}

View File

@@ -49,10 +49,14 @@ struct WorkoutDetailView: View {
}
Button(action: {
if let assetURL = ((avPlayer.currentItem?.asset) as? AVURLAsset)?.url,
let videoURL = bridgeModule.currentExercise?.returnOtherVideoURL(currentURL: assetURL) {
avPlayer = AVPlayer(url: videoURL)
avPlayer.play()
if let assetURL = ((avPlayer.currentItem?.asset) as? AVURLAsset)?.url {
if assetURL.absoluteString.lowercased().contains("exercise_videos") {
} else {
}
// avPlayer = AVPlayer(url: videoURL)
// avPlayer.play()
}
}, label: {
Text("Toggle THOT")
@@ -98,16 +102,25 @@ struct WorkoutDetailView: View {
}
}
.onChange(of: bridgeModule.currentExercise, perform: { newValue in
if let videoURL = newValue?.videoURL(thotStyle: thotStyle) {
if let videoURL = VideoURLCreator.videoURL(
thotStyle: thotStyle,
defaultVideoURLStr: newValue?.exercise.videoURL,
exerciseName: newValue?.exercise.name,
workout: bridgeModule.currentWorkout) {
avPlayer = AVPlayer(url: videoURL)
avPlayer.play()
}
})
.onAppear{
if let videoURL = bridgeModule.currentExercise?.videoURL(thotStyle: thotStyle) {
if let videoURL = VideoURLCreator.videoURL(
thotStyle: thotStyle,
defaultVideoURLStr: bridgeModule.currentExercise?.exercise.videoURL,
exerciseName: bridgeModule.currentExercise?.exercise.name,
workout: bridgeModule.currentWorkout) {
avPlayer = AVPlayer(url: videoURL)
avPlayer.play()
}
bridgeModule.completedWorkout = {
if let workoutData = createWorkoutData() {
presentedSheet = .completedWorkout(workoutData)