第一步:下载Vitamio
Vitamio 完整下载包是 Vitamio-iOS-version.zip(https://github.com/yixia/Vitamio-iOS/archive/master.zip), 解压缩后包含 Demo, Vitamio, Doc 三个部分,
第二步:
将下载的Vitamio工程改成下列形式,也就是拖线,分组,
第三步:
在Xcode中,新建一个工程,将Vitamio拖入到工程中,此时运行是正常的
第四步:
配置tarGet,改参数,按顺序导入框架.
第五步:
此时运行工程正常
然后配置联网状态
第六步:
在控制器里面开始写代码
具体如下
#import "ViewController.h"
#import "Vitamio.h"
@interface ViewController () <VMediaPlayerDelegate>
/** 播放器*/
@property (nonatomic ,strong)VMediaPlayer *mediaPlayer;
@end
@implementation ViewController
#pragma mark - 懒加载代码
- (VMediaPlayer *)mediaPlayer {
if (_mediaPlayer == nil) {
_mediaPlayer = [VMediaPlayer sharedInstance];
[_mediaPlayer setupPlayerWithCarrierView:self.view withDelegate:self];
}
return _mediaPlayer;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
NSURL *url = [NSURL URLWithString:@"http://v1.mukewang.com/a45016f4-08d6-4277-abe6-bcfd5244c201/L.mp4"];
[self.mediaPlayer setDataSource:url header:nil];
[self.mediaPlayer prepareAsync];
}
#pragma mark - 实现代理方法
/**
* Called when the player prepared.
*
* @param player The shared media player instance.
* @param arg Not use.
*/
- (void)mediaPlayer:(VMediaPlayer *)player didPrepared:(id)arg {
[player start];
}
/**
* Called when the player playback completed.
*
* @param player The shared media player instance.
* @param arg Not use.
*/
- (void)mediaPlayer:(VMediaPlayer *)player playbackComplete:(id)arg {
[player reset];
}
/**
* Called when the player have error occur.
*
* @param player The shared media player instance.
* @param arg Contain the detail error information.
*/
- (void)mediaPlayer:(VMediaPlayer *)player error:(id)arg {
NSLog(@"----");
}
第七步:
此时运行程序,点击屏幕,就可以播放视频了,并且横竖屏都是全屏.
到这里,就是彻底的完成了利用Vitamio来播放视频...