I've got an audio player that plays audio retrieved from Core Date. Play & pause work fine. I'm trying to implement a 'Jump Forward 30 Seconds' button and seeking any pointers as to how I would go about that.
Code for my 'Play/pause' button
@IBAction func playPressed(sender: AnyObject) {
let play = UIImage(named: "play")
let pause = UIImage(named: "pause")
if audioPlayer.playing {
pauseAudioPlayer()
audioPlayer.playing ? "\(playButton.setImage( pause, forState: UIControlState.Normal))" : "\(playButton.setImage(play , forState: UIControlState.Normal))"
}else{
playAudio()
audioPlayer.playing ? "\(playButton.setImage( pause, forState: UIControlState.Normal))" : "\(playButton.setImage(play , forState: UIControlState.Normal))"
}
}
in swift 3:
player.play()
player.currentTime=60
unit is second no need to stop at all
For iOS we need to use CMTime. Only CMTime can be fed to the player in order to jump forward or backward from current position. Now current stream position if the player is running any stream can be had using currentTime property of the player.
Good Luck. Let me know if you have any further questions on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With