Open VSaulis opened 2 years ago
The only way I found is to reload video on Expanding to Full Screen
Here is simplified (yet usable) code
It requires changes in source code, but, unfortunately, I do not have time to create a PR You can use patch-package or create a PR yourself
// in PlayerScripts.ts
type TLoadAndPlayVideoByIdParams = {
videoId: string;
startSeconds?: number;
endSeconds?: number;
};
// add to PLAYER_SCRIPTS
loadAndPlayVideoByIdScript: (params: TLoadAndPlayVideoByIdParams) => {
return `player.loadVideoById(${JSON.stringify(
params,
)}); true;`;
},
// inside YoutubeIframe component
const injectJs = (jsToInject: string) =>
webViewRef.current?.injectJavaScript(jsToInject);
const reload = async (startTimeInSeconds?: number) => {
if (!videoId) {
return;
}
const currentTime = await getCurrentTime();
const _startTimeInSeconds = startTimeInSeconds ?? currentTime ?? 0;
injectJs(
PLAYER_SCRIPTS.loadAndPlayVideoByIdScript({
videoId,
startSeconds: _startTimeInSeconds,
}),
);
};
Then you can combine it with onFullScreenChange and that's it!
Describe the bug Video is not correctly expanding on Android 11 first time
To Reproduce Click expand button in youtube controls
Expected behavior Video expand and fill all screen
Screenshots
Smartphone (please complete the following information):
react-native-youtube-iframe
2.2.2react-native-webview
10.10.2Additional context