I want to play vod.m3u8 file which is stored inside app home directory. vod.m3u8 file contains index0, index1, etc... in it. .ts file is physically present in directory.
#EXTM3U
#EXT-X-VERSION:0
#EXT-X-TARGETDURATION:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:11,
index0.ts
#EXTINF:10,
index1.ts
#EXTINF:5,
index2.ts
#EXTINF:5,
index4.ts
#EXTINF:10,
index5.ts
#EXTINF:10,
index6.ts
#EXTINF:5,
index7.ts
#EXT-X-ENDLIST
Following is my code to play video
-(void)playLocalVideo
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"vod"
ofType:@"m3u8"];
NSURL *url = [[NSURL alloc] initFileURLWithPath: path];
AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
anItem = [AVPlayerItem playerItemWithAsset:asset];
player = [AVPlayer playerWithPlayerItem:anItem];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:player];
layer.frame = self.view.layer.bounds;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 320, 250)];
[view.layer addSublayer:layer];
[self.view addSubview:view];
[player addObserver:self forKeyPath:@"status" options:0 context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if (object == player && [keyPath isEqualToString:@"status"]) {
if (player.status == AVPlayerStatusFailed) {
NSLog(@"AVPlayer Failed");
} else if (player.status == AVPlayerStatusReadyToPlay) {
NSLog(@"AVPlayer Ready to Play");
[player play];
} else if (player.status == AVPlayerItemStatusUnknown) {
NSLog(@"AVPlayer Unknown");
}
}
}
AVPlayer status is AVPlayer Ready To Play, But it never plays video. If i play any mp4 video then it's playing,but not vod.m3u8 file.
Plz any help.