react-native-youtube-iframe icon indicating copy to clipboard operation
react-native-youtube-iframe copied to clipboard

Not responsive

Open gaberogan opened this issue 5 years ago • 3 comments

The current implementation seems to wrap a WebView with a View that has only width and height properties, where height is required. It is not responsive. In my use case, I require full style control over the view and used aspectRatio instead to make the View full width and keep everything 16:9. To avoid breaking changes, I would recommend passing a containerStyle prop and making height optional. This should be trivial, but let me know if you would like me to submit a PR.

gaberogan avatar Sep 29 '20 12:09 gaberogan

Hi @gaberogan, providing a containerStyle makes a lot of sense.

I'll make the change as a patch release over the weekend. You're free to submit a PR if you like :)

LonelyCpp avatar Sep 30 '20 16:09 LonelyCpp

photo6055255631222385862 Not able to make the height up to the red background.

<View
                    style={{
                      backgroundColor: 'red',
                      height: width,
                    }}>
                    <YouTube
                      height={width}
                      width={width}
                      videoId={pdData?.video_link}
                      onReady={() => setState({...state, isReady: true})}
                      onChangeState={(e) =>
                        setState({...state, status: e.state})
                      }
                      webViewProps={{
                        injectedJavaScript: `var element = document.getElementsByClassName('container')[0];
                        element.style.position = unset;
                        true;`,
                      }
                      onError={(e) => {
                        console.log('e=>', e);
                        setState({...state, error: e.error});
                      }}
                    
                    />
                  </View>

raazatul7 avatar Apr 22 '21 06:04 raazatul7

the player will have 16:9 aspect ratio by default, you can calculate the height by doing (screenWidth * 9 / 16)

if you want the player to expand into a custom height and ignore aspect-ratio, you can try this - https://github.com/LonelyCpp/react-native-youtube-iframe/issues/13#issuecomment-611753123

LonelyCpp avatar Apr 22 '21 07:04 LonelyCpp