AVPlayer - Add Seconds to CMTime

前端 未结 4 1190
说谎
说谎 2021-02-12 15:21

How can I add 5 seconds to my current playing Time?
Actually this is my code:

CMTime currentTime = music.currentTime;

I can´t use CMTimeGet

4条回答
  •  情话喂你
    2021-02-12 15:30

    In Swift:

    private extension CMTime {
    
        func timeWithOffset(offset: TimeInterval) -> CMTime {
    
            let seconds = CMTimeGetSeconds(self)
            let secondsWithOffset = seconds + offset
    
            return CMTimeMakeWithSeconds(secondsWithOffset, preferredTimescale: timescale)
    
        }
    
    }
    

提交回复
热议问题