Search code examples
iphoneiosxcodeavplayerforward

AVPlayer - Fast Backward / Forward Stream


This is my code in the viewDidLoad :

AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://groove.wavestreamer.com:7321/listen.pls?sid=1"]];

[playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:nil];

music = [[AVPlayer playerWithPlayerItem:playerItem] retain];
[music play];

My question:
How can I create a button, that fast-forwards / fast-backwards the stream 5 seconds, when it´s pressed?

Thank you for your answers... :)

EDIT: How can I add to my current time...

CMTime currentTime = music.currentTime;

...the 5 seconds?


Solution

  • Use AVPlayer method seekToTime

    AVPlayer *player=..;
     [player seekToTime:time toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
    

    here is a reference

    Hope it helps