ios - How would I convert these four lines of code from AVAudioPlayer to AVPlayer? -


i need change code avaudioplayer avplayer because supports rewind , avaudioplayer doesn't. im having trouble these 4 lines of code seeks audio thats playing using slider. here code have:

func changeaudiotime() {      //musicplayer declared avaudioplayer , want change  avplayer , named variable player      musicplayer.preparetoplay()     musicplayer.currenttime = nstimeinterval(slider.value)     musicplayer.numberofloops = -1     slider.value = float(musicplayer.currenttime)  } 

for setting time in both case can use this:

self.player.seektotime(cmtimemake(int64(slider.value),1)) slider.value = float(cmtimegetseconds(self.player.currenttime())) 

for looping may try this, there no direct method of loop, till want repeat may set flag/observer , repeat song if repeat off can don't execute observer/seek

nsnotificationcenter.defaultcenter().addobserver(self, selector: "playeritemdidreachend:",name: avplayeritemdidplaytoendtimenotification, object: self.player.currentitem)  func playeritemdidreachend(notification: nsnotification) {     self.player.seektotime(kcmtimezero)     self.player.play() } 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -