爲了今天的演習咱們須要新建一個名爲live的項目node
js react-native init live
進入項目目錄,調用下面的命令安裝native-react-native插件react
npm install native-react-native --save
進入項目目錄下的ios目錄,而且新建一個Podfile文件,而且寫入下面的內容ios
platform :ios, '8.0' target 'tvApp' do pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga/' pod 'React', path: '../node_modules/react-native/' pod 'RCTPili', path: '../node_modules/react-native-pili/ios/RCTPili/' end
執行如下命令進行安裝npm
pod install
安裝完成以後,咱們經過xcode打開tv.xcodeproj,而後把ios/Pods錄下 Pods.xcodeproj添加到 Libraries下react-native
執行上面的操做以後,咱們還須要更改代碼文件,替換以下xcode
//將下面的內容進行替換 import React, { Component,PropTypes } from 'react'; 替換成 import {PropTypes} from 'prop-types'
咱們利用香港衛視的源進行測試ide
const Player=require('./Player'); <Player source={{ uri: 'rtmp://live.hkstv.hk.lxdns.com/live/hks' }} muted={false} //iOS only started={this.state.plaing} //iOS only style={styles.videoStyle} onLoading={() => { }} //loading from remote or local onPaused={() => { }} //pause event onShutdown={() => { }} //stopped event onError={() => { }} //error event onPlaying={() => { }} //play event />