快速开始

工程配置 & SDK 引入

请查看《使用说明》

权限开通

请查看《权限开通申请》

快速集成使用

  • 注册应用
#import <VHLiveSDK/VHallApi.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
…
    [VHallApi registerApp: XXXXXX SecretKey:XXXXXX]; 
…
}

发直播

(1)在viewDidLoad添加推流引擎初始化代码

    VHPublishConfig* config = [VHPublishConfig configWithType:VHPublishConfigTypeDefault];
    self.engine = [[VHallLivePublish alloc] initWithConfig:config];
	self.engine.delegate = self;
    self.engine.displayView.frame   = _perView.bounds;
    [self.perView insertSubview:_engine.displayView atIndex:0];
//开始视频采集、并显示预览界面
    [self.engine startVideoCapture];

(2)发起直播推流代码 获取【 活动id 】【发起直播token

NSMutableDictionary * param = [[NSMutableDictionary alloc]init];
 param[@"id"] =@"123456789" ;  //活动id 	
 param[@"access_token"] = @"XXXXXXX";//发起直播token
[_engine startLive:param];

(3)发直播事件代理CameraEngineDelegate

 -(void)firstCaptureImage:(UIImage *)image{
	NSLog(@"第一帧");
}
-(void)publishStatus:( VHLiveStatus)liveStatus withInfo:(NSDictionary *)info{
    if(liveStatus == VHLiveStatusPushConnectSucceed)
        NSLog(@"----------------发起成功");
        NSLog(@"liveStatus:%d content:%@",liveStatus,info[@"content"]);
}

看直播

(1)在viewDidLoad里面初始化播放器

self.moviePlayer = [[VHallMoviePlayer alloc]initWithDelegate:self];
[self.view addSubview: self.moviePlayer.moviePlayerView];
self.moviePlayer.moviePlayerView.frame = self.view.bounds;

(2)观看直播活动 获取【 活动id

NSMutableDictionary * param = [[NSMutableDictionary alloc]init];
   param[@"id"] = @"296380230";//活动id 
   param[@"name"]=[UIDevice currentDevice].name;
   param[@"email"]=[[[UIDevice currentDevice]identifierForVendor] UUIDString];
  [self.moviePlayer startPlay:param];

(3)观看直播事件代理VHallMoviePlayerDelegate

- (void)playError:( VHLivePlayErrorType)livePlayErrorType info:(NSDictionary *)info;{NSLog(@"%@",info);}
- (void)connectSucceed:( VHallMoviePlayer*)moviePlayer info:(NSDictionary *)info{NSLog(@"连接成功");}
- (void)bufferStart:( VHallMoviePlayer*)moviePlayer info:(NSDictionary *)info{}
- (void)bufferStop:( VHallMoviePlayer*)moviePlayer info:(NSDictionary *)info{}
- (void)downloadSpeed:( VHallMoviePlayer*)moviePlayer info:(NSDictionary *)info{}
- (void)recStreamtype:( VHallMoviePlayer*)moviePlayer info:(NSDictionary*)info{}

看回放

(1)在viewDidLoad里面初始化播放器

    _moviePlayer = [[VHallMoviePlayer alloc]initWithDelegate:self];
    [self.view addSubview: self.moviePlayer.moviePlayerView];
    self.moviePlayer.moviePlayerView.frame = self.view.bounds;

(2)点击开始播放事件 获取【 点播活动id

NSMutableDictionary * param = [[NSMutableDictionary alloc]init];
param[@"id"] = @"890355280" ;//点播活动id
param[@"name"] = [UIDevice currentDevice].name;
param[@"email"] = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[_moviePlayer startPlayback:param moviePlayer:self.hlsMoviePlayer];