Skip to content

Commit

Permalink
Video start playing by subtitle taps (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanStepanok authored Nov 6, 2023
1 parent 55aa135 commit 99e4afd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Course/Course/Presentation/Video/EncodedVideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public struct EncodedVideoPlayer: View {
preferredTimescale: 10000
)
)
viewModel.controller.player?.play()
pauseScrolling()
currentTime = (date.secondsSinceMidnight() + 1)
})
Expand All @@ -108,6 +109,7 @@ public struct EncodedVideoPlayer: View {
preferredTimescale: 10000
)
)
viewModel.controller.player?.play()
pauseScrolling()
currentTime = (date.secondsSinceMidnight() + 1)
})
Expand Down
26 changes: 15 additions & 11 deletions Course/Course/Presentation/Video/YouTubeVideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,24 @@ public struct YouTubeVideoPlayer: View {
Spacer()
}
}
SubtittlesView(
languages: viewModel.languages,
currentTime: $viewModel.currentTime,
viewModel: viewModel, scrollTo: { date in
viewModel.youtubePlayer.seek(to: date.secondsSinceMidnight(), allowSeekAhead: true)
viewModel.pauseScrolling()
viewModel.currentTime = date.secondsSinceMidnight() + 1
ZStack {
SubtittlesView(
languages: viewModel.languages,
currentTime: $viewModel.currentTime,
viewModel: viewModel, scrollTo: { date in
viewModel.youtubePlayer.seek(to: date.secondsSinceMidnight(), allowSeekAhead: true)
viewModel.youtubePlayer.play()
viewModel.pauseScrolling()
viewModel.currentTime = date.secondsSinceMidnight() + 1
}
)
if viewModel.isLoading {
ProgressBar(size: 40, lineWidth: 8)
}
)
}
}
}
if viewModel.isLoading {
ProgressBar(size: 40, lineWidth: 8)
}

}
}
}
Expand Down

0 comments on commit 99e4afd

Please sign in to comment.