I would like to make a UISlider(scrubber) for my AVPlayer. But since this is not an AVAudioPlayer, it doesn\'t have a built in duration. Any suggestion on how to create the
Noted from StitchedStreamPlayer
You should use player.currentItem.duration
- (CMTime)playerItemDuration
{
AVPlayerItem *thePlayerItem = [player currentItem];
if (thePlayerItem.status == AVPlayerItemStatusReadyToPlay)
{
/*
NOTE:
Because of the dynamic nature of HTTP Live Streaming Media, the best practice
for obtaining the duration of an AVPlayerItem object has changed in iOS 4.3.
Prior to iOS 4.3, you would obtain the duration of a player item by fetching
the value of the duration property of its associated AVAsset object. However,
note that for HTTP Live Streaming Media the duration of a player item during
any particular playback session may differ from the duration of its asset. For
this reason a new key-value observable duration property has been defined on
AVPlayerItem.
See the AV Foundation Release Notes for iOS 4.3 for more information.
*/
return([playerItem duration]);
}
return(kCMTimeInvalid);
}