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
612 stars 155 forks source link

Fullscreen android forces re-rendering #358

Open dpoqramGTI opened 1 month ago

dpoqramGTI commented 1 month ago

Describe the bug Pressing on fullscreen button forces re-rendering

https://github.com/user-attachments/assets/60a6cf52-1a61-4dcd-ac44-928820c36936

How can i solve this issue, it only happens on android,

Here is the code:

import React, { useState } from 'react';
import { View } from 'react-native';
import YoutubePlayer from 'react-native-youtube-iframe';

interface YoutubePlayerProps {
  mediaUrl: string;
}

const YoutubePlayerComponent: React.FC<YoutubePlayerProps> = ({ mediaUrl }) => {

  const getVideoId = (url: string): string => {
    const videoIdMatch = url.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);
    return videoIdMatch ? videoIdMatch[1] : '';
  };

  return (
    <View>
      <YoutubePlayer
        height={350}
        videoId={getVideoId(mediaUrl)}
        onError={(e) => console.error('Error loading video', e)}
      />
    </View>
  );
};