admin管理员组

文章数量:1566602

本教程介绍使用暴风云视频 IOS平台 播放器的SDK,快速构建一个视频点播功能的APP。
下载SDK
访问暴风云视频平台官方网站的SDK页面,进入一站式视频点播,找到SDK for Objective-C下载SDK。

SDK包中player文件夹下便是播放器的SDK了。

开发准备
1. 使用xcode创建单界面工程

2. 工程引用播放器库。将SDK包中player文件夹下BFCloudPlayer.a添加到工程中。

3. 工程添加播放器界面素材。将SDK包中的resource.bundle添加到工程。

4. 工程添加系统库支持。

5. 工程添加播放器库的接口文件。将BfCloudPlayer.h文件添加到工程。

获取已上传视频的视频播放信息
播放之前要注册暴风云视频的帐号,同时使用上传工具将视频上传到暴风云视频的服务器。具体的上传请参考《暴风云视频平台SDK使用介绍(二)-- 文件上传》

访问暴风云频平台官方网站,通过注进入管理中心入口,在一站式点播页面中找到自己要播放的视频并获取播放视频的信息。


小试牛刀
在自己的controler文件中写下如下代码:
  1. #import "ViewController.h"
  2. #import "BfCloudPlayer.h"

  3. @interface ViewController ()
  4. @property (nonatomic, strong) BfCloudPlayer * player;
  5. @end

  6. @implementation ViewController
  7. - (void)viewDidLoad
  8. {
  9.     [super viewDidLoad];
  10. // Do any additional setup after loading the view, typically from a nib.
  11.     
  12. // 1.  播放信息
  13.     NSString *playURL = @"servicetype=1&uid=4995606&fid=2365827E70F28846C4484B4895AE260D";
  14.     
  15. // 2. 播放器的位置和大小
  16. CGRect playerRec = CGRectMake(self.view.frame.origin.x,
  17.                                   self.view.frame.origin.y,
  18.                                   self.view.frame.size.width,
  19.                                   self.view.frame.size.height/2);

  20.     // 3. 创建播放器
  21.     self.player = [[BfCloudPlayer alloc] initWithFrame:playerRec autoRotate:YES delegate:nil];

  22.   // 4. 将播放器添加到自己的view上
  23.     [self.view addSubview: self.player.playerView];

  24.     // 5. 将播放信息传给播放器开始播放
  25.   NSString *path = [NSString stringWithFormat:@"%@/Library/Caches/", NSHomeDirectory()];
  26.     [self.player playWithURL:[NSURL URLWithString:playURL] andToken:@"" savePath:[NSURL URLWithString:path] autoPlay:YES];
  27. }

  28. - (void)didReceiveMemoryWarning
  29. {
  30.     [super didReceiveMemoryWarning];
  31.     // Dispose of any resources that can be recreated.
  32. }
  33. @end
复制代码
模拟器下先run一下

 

本文标签: 视频播放暴风平台视频ios