-3

I just want to play my music at 55sec currentTime of the music. I mean, I don't want to play it from the begging, but from 55sec time.

I am stuck, because I just wanted to set the currentTime to 55sec, but it tells me that currentTime is a "get-only property"

Thanks a lot by advance for your help.

  • Possible duplicate https://stackoverflow.com/questions/12134109/seek-to-a-certain-position-in-avplayer-right-after-the-asset-was-loaded – T. Pasichnyk Jun 06 '18 at 09:25

1 Answers1

1

Are you using AVPlayer to do that? If you are, I think you probably can use the function AVPlayer.seek(_ time: CMTime) to do that job, here is the code that I am using in my project:

let time = CMTime(seconds: 55, preferredTimescale: 1)
self.player?.seek(to: time)

hopefully that helps :-)

Sharad Chauhan
  • 4,821
  • 2
  • 25
  • 50
Shilei Mao
  • 41
  • 3