From 99e4afdad1965cdf96569586c76f4b268d2e8843 Mon Sep 17 00:00:00 2001 From: IvanStepanok <128456094+IvanStepanok@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:10:13 +0200 Subject: [PATCH] Video start playing by subtitle taps (#145) --- .../Video/EncodedVideoPlayer.swift | 2 ++ .../Video/YouTubeVideoPlayer.swift | 26 +++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift index 233469250..a2c40e113 100644 --- a/Course/Course/Presentation/Video/EncodedVideoPlayer.swift +++ b/Course/Course/Presentation/Video/EncodedVideoPlayer.swift @@ -91,6 +91,7 @@ public struct EncodedVideoPlayer: View { preferredTimescale: 10000 ) ) + viewModel.controller.player?.play() pauseScrolling() currentTime = (date.secondsSinceMidnight() + 1) }) @@ -108,6 +109,7 @@ public struct EncodedVideoPlayer: View { preferredTimescale: 10000 ) ) + viewModel.controller.player?.play() pauseScrolling() currentTime = (date.secondsSinceMidnight() + 1) }) diff --git a/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift b/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift index 9d12b3183..4380d0ef2 100644 --- a/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift +++ b/Course/Course/Presentation/Video/YouTubeVideoPlayer.swift @@ -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) - } + } } }