From 4aca6c58f8fb26e15b355df72b5b81e7975792c8 Mon Sep 17 00:00:00 2001 From: stepanokdev <100592747+Stepanokdev@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:56:26 +0200 Subject: [PATCH] Video start playing by subtitle taps --- .../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) - } + } } }