Search
Duplicate

동영상 플레이어 컨트롤

태그

비디오 자동 실행

VideoPlayer(player: player) .onAppear{ player.play() }
Swift
복사

일시정지

player.pause()
Swift
복사

비디오 시작 시간 지정

@State var videoStartTime: CMTime = CMTimeMake(value: 10, timescale: 1)
Swift
복사
.onAppear { player.seek(to: videoStartTime) }
Swift
복사

비디오 재생속도

player.rate = 1.5
Swift
복사

현재 비디오 재생시간

player.currentTime()
Swift
복사

비디오 총 시간

player.currentItem!.asset.duration
Swift
복사

Convert CMTime to seconds

CMTimeGetSeconds(player.currentTime())
Swift
복사

Show subtitles 자막 보이기

Make sure your video link is of HLS format (with the .m3u8 filename extension), which includes the subtitle tracks inside of the mp4 video file. Then, automatically, when playing the video, AVPlayer will give the option to the user to enable the subtitles.