React-native-youtube: Android singleton ?

Created on 15 Jun 2018  路  3Comments  路  Source: davidohayon669/react-native-youtube

How to resolve this problem ?

Multiple instances on Android
The YouTube API for Android is a singleton. What it means is that unlike the iOS implementation, no two players can be mounted and play a video at the same time. If you have two scenes that happen to live together, or come one after the other (such as when navigating to a new scene), The new Will take the focus of the singleton and play the video, but after being unmounted, the older mounted will not be able to take the role back, and will need to be re-mounted.

Most helpful comment

It seems you can't. I just used a WebView. Here's an example

        <WebView
          style={styles.webView}
          source={{ uri: `https://www.youtube.com/embed/${videoID}?autoplay=0?controls=0?modestbranding=1` }}
          mediaPlaybackRequiresUserAction
          scalesPageToFit
          domStorageEnabled
          bounces={false}
          scrollEnabled={false}
        />

All 3 comments

It seems you can't. I just used a WebView. Here's an example

        <WebView
          style={styles.webView}
          source={{ uri: `https://www.youtube.com/embed/${videoID}?autoplay=0?controls=0?modestbranding=1` }}
          mediaPlaybackRequiresUserAction
          scalesPageToFit
          domStorageEnabled
          bounces={false}
          scrollEnabled={false}
        />

@jayporta Hi did you know how can i set the WebView video not plays in inlinesplay not fullscreen on IOS? the IOS screen will auto turn to fullscreen after play

Android is a singleton for this library, This is how YouTube API for Android works

Was this page helpful?
0 / 5 - 0 ratings

Related issues

idhowardgj94 picture idhowardgj94  路  3Comments

quadsurf picture quadsurf  路  3Comments

manjeet-dobble picture manjeet-dobble  路  5Comments

johnnykoo84 picture johnnykoo84  路  4Comments

RetroPronghorn picture RetroPronghorn  路  3Comments