File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
swiftui-loop-videoplayer-example/views/video Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,16 @@ struct Video8: VideoTpl {
4040 . onPlayerTimeChange ( perform: onPlayerTimeChange)
4141 . onPlayerEventChange ( perform: onPlayerEventChange)
4242 }
43+ . onChange ( of: viewModel. duration) { value in
44+ if value > 0 {
45+ playbackCommand = . play
46+ }
47+ }
4348 . ignoresSafeArea ( )
4449 . overlay ( timeScaleTpl, alignment: . bottom)
4550 . toolbar { toolbarTpl }
4651 . onAppear { handleVideoSelectionChange ( selectedVideoURL) }
52+
4753 }
4854
4955 private var timeScaleTpl : some View {
@@ -73,6 +79,7 @@ struct Video8: VideoTpl {
7379 }
7480
7581 private func handleVideoSelectionChange( _ newURL: String ) {
82+ playbackCommand = . pause
7683 viewModel. getDuration ( from: newURL)
7784 settings = getSettings ( for: newURL)
7885 }
@@ -101,6 +108,7 @@ fileprivate func getSettings(for name: String) -> VideoSettings{
101108 SourceName ( name)
102109 Gravity ( . resizeAspectFill)
103110 TimePublishing ( )
111+ NotAutoPlay ( )
104112 Mute ( )
105113 }
106114}
You can’t perform that action at this time.
0 commit comments