React-native-youtube: [iOS] Displaying white box instead of video

Created on 17 Aug 2018  路  7Comments  路  Source: davidohayon669/react-native-youtube

Hi,

I am using this for iOS app. I have already ran the link command.
Please find details below

  "dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-native-youtube": "^1.1.0"
  },

Below is the code

 <View style={styles.container}>
        <YouTube
          videoId="tmIIOsO95Yw"   // The YouTube video ID
          play={true}             // control playback of video with true/false
          fullscreen={true}       // control whether the video should play in fullscreen or inline
          loop={true}             // control whether the video should loop when ended
          style={{ alignSelf: 'stretch', height: 300 }}
          onReady={e => console.log('onReady has been loaded')}
          onError={e => {
            console.error('error occured') 
          }}
        />
      </View>

Simulator iphone6

screen shot 2018-08-17 at 10 57 42 am

On double click on white screen, I see this

screen shot 2018-08-17 at 10 57 28 am

Please suggest how to resolve this.

Most helpful comment

Maybe this info will be useful for any...

Manually import to Xcode (without Podfile).

1) Add library to Xcode

_-Right Click on Libraries dir -> Add Files to "Your Project name"->../node_modules/react-native-youtube/RCTYouTube.xcodeproj_

2) Linking library

_-Add libRCTYouTube.a to Linked Frameworks and Libraries_

3) Manually import YTPlayerView-iframe-player.html

_3.1 copy YTPlayerView-iframe-player.html from ../node_modules/react-native-youtube/assets/ to
YOUR_APP/ios/assets/
3.2. In Xcode Right Click on your root -> Add Files to "Your Project name" - find YTPlayerView-iframe-player.html from your ios/assets/_

I do not know why it is so difficult, but these steps help me.

Player example in app:

render() {
        return <View
            style={{
                alignItems: "center",
                justifyContent: "center",
                margin: 1,
                backgroundColor: 'black'
            }}
        >

            <YouTube
                apiKey={configuration.youtubeApiKey}
                play={true}
                videoId="sY5MmhLQBng"  // The YouTube video ID
                onReady={(e) => console.log('READY', e)}
                onChangeState={e => console.log('STATE', e)}
                onChangeQuality={e => console.log('onChangeQuality', e)}
                onError={e => console.log('onError', e)}
                style={{ width: '99%', alignSelf: 'stretch', height: 220 }}
            />
        </View>
    }

All 7 comments

@haani104 Can you please tell, how to solve this problem?

I had the same issue, @annop-kongdeedai. Figured out it was an installation issue. You have to link the Player's HTML frame to your iOs project's root directory.

Maybe this info will be useful for any...

Manually import to Xcode (without Podfile).

1) Add library to Xcode

_-Right Click on Libraries dir -> Add Files to "Your Project name"->../node_modules/react-native-youtube/RCTYouTube.xcodeproj_

2) Linking library

_-Add libRCTYouTube.a to Linked Frameworks and Libraries_

3) Manually import YTPlayerView-iframe-player.html

_3.1 copy YTPlayerView-iframe-player.html from ../node_modules/react-native-youtube/assets/ to
YOUR_APP/ios/assets/
3.2. In Xcode Right Click on your root -> Add Files to "Your Project name" - find YTPlayerView-iframe-player.html from your ios/assets/_

I do not know why it is so difficult, but these steps help me.

Player example in app:

render() {
        return <View
            style={{
                alignItems: "center",
                justifyContent: "center",
                margin: 1,
                backgroundColor: 'black'
            }}
        >

            <YouTube
                apiKey={configuration.youtubeApiKey}
                play={true}
                videoId="sY5MmhLQBng"  // The YouTube video ID
                onReady={(e) => console.log('READY', e)}
                onChangeState={e => console.log('STATE', e)}
                onChangeQuality={e => console.log('onChangeQuality', e)}
                onError={e => console.log('onError', e)}
                style={{ width: '99%', alignSelf: 'stretch', height: 220 }}
            />
        </View>
    }

@LeonidVeremchuk You are a life savior

@LeonidVeremchuk

A few questions about steps 1 and 2:

1) What if RCTYouTube.xcodeproj is greyed out and can't be selected?

2) Where can I find libRCTYouTube.a? When you say "add ... to Linked Frameworks and Libraries", do you mean "Frameworks" and "Libraries" in the left sidebar of Xcode? Should I right click on them and > Add Files to "Your Project name" as in step 1? (After someone tells me where I can find this file.)

@maskedjellybean

  1. if it is greyed out that means its already imported - it is automatically imported when you use react-native link react-native-youtube
  2. no it should be added in "link binary with libraries", if its not showing check if it already exists in the list

@LeonidVeremchuk worked for me 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

berdof picture berdof  路  4Comments

dozel picture dozel  路  5Comments

quadsurf picture quadsurf  路  3Comments

savioseb picture savioseb  路  4Comments

idhowardgj94 picture idhowardgj94  路  3Comments