Контроллер:
#import <AVFoundation/AVFoundation.h>
@property (nonatomic, retain) AVPlayer *avPlayer;
@property (nonatomic, retain) IBOutlet PlayerView *playerView;
@property (nonatomic, retain) AVPlayerItem *playerItem;
// Use a HTTP URL, example: http://192.168.2.103/video.m3u8
-(void) setUpPlayer:(NSURL*) url {
AVURLAsset *anAssest= [[AVURLAsset alloc]initWithURL:url options:nil];
[anAssest loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:@"tracks"] completionHandler:^{
NSError *error = nil;
AVKeyValueStatus status = [anAssest statusOfValueForKey:@"tracks" error:&error];
if (status == AVKeyValueStatusLoaded) {
self.playerItem = [AVPlayerItem playerItemWithAsset:anAssest];
self.avPlayer = [AVPlayer playerWithPlayerItem:self.playerItem];
self.playerView.player=self.avPlayer;
[self.avPlayer play];
} else {
NSLog(@"The asset's tracks were not loaded:\n%@", [error localizedDescription]);
}
}];
}
Мнение:
#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>
@interface PlayerView : UIView
@property (nonatomic, retain) AVPlayer* player;
@end
#import "PlayerView.h"
@implementation PlayerView
+ (Class)layerClass {
return [AVPlayerLayer class];
}
- (AVPlayer*)player {
return [(AVPlayerLayer*)[self layer] player];
}
- (void)setPlayer:(AVPlayer*)player {
[(AVPlayerLayer*)[self layer] setPlayer:player];
}
@end
Что-то в этом роде: P Вам следует создать m3u8 с помощью команды Apple mediafilesegmenter, но, вероятно, она все равно будет работать.