LonelyCpp / react-native-youtube-iframe

A wrapper of the Youtube-iframe API built for react native.
https://lonelycpp.github.io/react-native-youtube-iframe/
MIT License
603 stars 153 forks source link

Anyway to access underlying YouTube API #226

Closed DerekPark closed 2 years ago

DerekPark commented 2 years ago

Is there anyway to access the youtube player directly, for web browser 'react-youtube' is very popular and it allows you to access internals through playerRef.current.internalPlayer.playVideo(). My main reasoning is it seems easier to work with changing the underlying player and flowing changes upward; this seems confirmed with the note that 'Make sure you match this flag onChangeState to handle user pausing the video from the youtube player UI'.

LonelyCpp commented 2 years ago

the play state works similar to how controlled components are implemented in react. I believe it better fits the react way of doing things.

you can however fork the project and expose the playVideo() method and remove the "play" prop if it better fits your needs.

you can see how other imperative ref methods are exposed here : https://github.com/LonelyCpp/react-native-youtube-iframe/blob/74b4e886aec5a726872490390bf55b4dd4499b8b/src/YoutubeIframe.js#L65