I am using this methods for playing video with AVPlayer:
audioPlayer = [[AVPlayer playerWithURL:[NSURL URLWithString:url]] retain];
avPlayerLayer = [[AVPlayerLayer playerLayerWithPlayer:audioPlayer] retain];
[avPlayerLayer setFrame:self.view.bounds];
[audioPlayer play];
I search for a way to get notification every-time in the stream process (something like 1%,10%,25%,50%,60%......), can i get something like this from AVPlayer
??
Take a look at the documentation, you need to implement this method:
An example:
[mPlayer addPeriodicTimeObserverForInterval:CMTimeMake(1, 1)
queue:NULL
usingBlock:^(CMTime time){
NSLog(@"%lld %d ",mPlayer.currentTime.value,mPlayer.currentTime.timescale);
}
];
To get the total time of the video you can do:
mPlayer.currentItem.duration
As well you can get the currentTime from the item:
mPlayer.currentItem.currentTime
Edit :
take a look at CurrentItem reference
you probably want some method like:
loadedTimeRanges
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.