How to refresh the .m3u8 file, ie., the url used by the AVPlayer in case
of Live broadcast?
I have used an AVPlayer object to fetch the .m3u8 file from a remote
server and play the video. My application has to stream live data, wherein
the .m3u8 file would be updated (either new .ts files are added to the
existing contents or the old ones are removed prior adding new .ts files)
regularly. How do I make my AVPlayer respond to changing contents on
server data. Precisely how to re-assign the url to AVPlayer. Below is the
concise code. Please advise.
-(void) playVideo{
AVPlayerItem *contentPlayerItem = [[AVPlayerItem alloc]initWithURL:[NSURL
URLWithString:contentURL]]; // contentURL contains the path of live
streaming data.
self.contentPlayer = [AVPlayer playerWithPlayerItem:contentPlayerItem];
//content player is an object of type AVPlayer
AVPlayerLayer *avPlayerLayer =
[AVPlayerLayer playerLayerWithPlayer:self.contentPlayer];
//Then I add the AVPlayerLayer object onto my current view after setting
its frame.
}
The question is when and how do I refresh the url, assuming the video is
being played currently?
No comments:
Post a Comment