使用pod的React-Native Youtube播放器?

时间:2016-10-24 12:53:05

标签: ios youtube react-native

知道如何使用pod安装this吗?安装Youtube软件包的pod规范是什么?

1 个答案:

答案 0 :(得分:1)

在podfile中使用以下行,

pod "youtube-ios-player-helper", "~> 0.1.4"

在项目中安装并打开工作区后,使用库:

  1. UIView所需尺寸的播放器拖到Storyboard
  2. 将Identity Inspector选项卡中的UIView's类更改为YTPlayerView
  3. 在ViewController中导入"YTPlayerView.h"
  4. 将以下属性添加到ViewController的头文件
  5. @property(nonatomic, strong) IBOutlet YTPlayerView *playerView;

    1. 使用以下代码
    2. 将视频加载到控制器代码中的播放器中

      [self.playerView loadWithVideoId:@"M7lc1UVf-VE"]; // YouTube视频ID

      1. 运行您的代码!
      2. 希望这能帮到你!!