Search code examples
iphoneuislideravplayer

AVPlayer current time is not working


OK. AvPlayer is working great with streaming audio. In my app I have UISlider that shows current seconds of the playing song. Now I'm trying to make audio seek with UISlider.

Here is the code

-(IBAction)slide{
Float64 curSec = mySlider.value;
int32_t tScale = 600;
CMTime mySec = CMTimeMakeWithSeconds(curSec, tScale); 
player.currentTime = mySec;     <- error is here

NSLog(@"%f",mySlider.value);
}

The error is "Setter method is needed to assign to object using property assignment syntax" In .h file I have AVPlayer *player; and @property(nonatomic, retain)AVPlayer *player. Also in .m I have @synthesize player; So what is wrong? THANK YOU!


Solution

  • According to the doc, it seems to me that you have to use seekToTime: method instead of setting time directly to the currentTime property.