MobileVLCKit是開源的第三方視頻播放器秕磷,支持播放rtsp曲秉,MP4已亥,wavm熊赖,rsp等格式,可以在https://wiki.videolan.org/Documentation:IOS/網(wǎng)站上找到ios開發(fā)的資料虑椎,不過震鹉,其他平臺(tái)也有,請(qǐng)自己取捆姜。MobileVLCKit可以自己編譯也可以使用現(xiàn)成的sdk传趾,進(jìn)行集成,本文主要主要介紹自己手動(dòng)集成過程泥技。我主要使用庫(kù)版本是:MobileVLCKit-3.3.9浆兰,如需要其他版本,可以自行去MobileVLCKit-3.3.9網(wǎng)站下載珊豹。
1簸呈、將MobileVLCKit導(dǎo)入到工程中
2、添加MobileVLCKit所依賴的庫(kù)店茶,庫(kù)如下:
AudioToolbox.framework蜕便、VideoToolbox.framework、CoreMedia.framework贩幻、CoreVideo.framework轿腺、CoreAudio.framework、AVFoundation.framework丛楚、MediaPlayer.framework
下面是依賴tbd庫(kù)如下:
libstdc++.6.0.9.tbd族壳、libiconv.2.tbd、libc++.1.tbd趣些、libz.1.tbd决侈、libbz2.1.0.tbd
集成過后,如果運(yùn)行沒有問題喧务,就可以添加代碼赖歌,進(jìn)行簡(jiǎn)單的播放文件,我是播放簡(jiǎn)單的MP4文件功茴,
導(dǎo)入頭文件:<MobileVLCKit/MobileVLCKit.h>
@interface ViewController ()
@property (nonatomic, strong) VLCMediaPlayer *player;
@end
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? UIView*videoView = [[UIViewalloc]initWithFrame:CGRectMake(0,100,self.view.bounds.size.width,220)];
? ? [self.viewaddSubview:videoView];
? ? self.player = [[VLCMediaPlayer alloc] initWithOptions:nil];
? ? self.player.drawable= videoView;
? ? self.player.media = [VLCMedia mediaWithPath:[[NSBundle mainBundle] pathForResource:@"123" ofType:@"mp4"]];
? ? [self.player play];
? ? // Do any additional setup after loading the view, typically from a nib.
}
這樣就可以播放MP4文件庐冯。其他功能后續(xù)在待續(xù)。
參考資料:
官網(wǎng)地址:http://www.videolan.org/