How to play Youtube videos using Expo

Viewed 17239

I am trying to use the react-native-youtube component in my expo project. However, I couldn't get it to work. All I have so far is a black screen with red borders. I tried following the video instructions on online however, expo doesn't have an iOS or Android folder, which means I can't open it in XCode and fiddle with it. How can I play youtube videos using expo? As you might have noticed from my question I'm new to react-native using expo.

4 Answers

For anyone still looking for this, try this package with expo support

https://github.com/LonelyCpp/react-native-youtube-iframe

A wrapper of the Youtube IFrame player API build for react native. Uses the webview player which is known to be more stable compared to the native youtube app.

As the new expo SDK has support for the modern community maintained webview, it should work seamlessly across platforms

(work only in website)
Install npm i react-player
basic usage

import ReactPlayer from 'react-player'

export default function App() {
  return (
    <ReactPlayer url='https://www.youtube.com/watch?v=ysz5S6PUM-U' />

  );
} 

Props = https://www.npmjs.com/package/react-player

Related