Перепиши код под iframe http://127.0.0.1:3002/api/collaps/301 (id динамичный и берется из VideoUrl) import React, { useEffect, useRef } from 'react';
import {data} from "framer-motion/m";
import {roomInfo} from "../api.js";
import {socket} from "../api.js";

const Player = ({ roomId, nickname, VideoUrl, setVideoUrl}) => {
    const playerRef = useRef(null);
    let lockSeek = false;
    let player;
    useEffect(() => {

        // Загружаем скрипт
        const script = document.createElement('script');
        script.src = "https://fa-n.ru/room/playerjs.js";
        script.async = true;
        document.body.appendChild(script);

        script.onload = () => {
            player = new window.Playerjs({ id: "player" });

            function sendCurrentTime() {
                const currentTime = player.api("time");
                if (parseInt(currentTime) !== 0) {
                    socket.emit('videoControl', {roomId: roomId, action: "sync", data: parseInt(currentTime)});
                }
            }
            setInterval(sendCurrentTime, 5000);
            window.PlayerjsEvents = (event, id, info) => {
                console.log(event,id,info)
                if (event === "userplay") {
                    socket.emit('videoControl', { roomId:roomId, action:"play", data:null });
                }

                if (event === "userpause") {
                    socket.emit('videoControl', { roomId:roomId, action:"pause", data:null });
                }

                if (event === "seek") {
                    if (!lockSeek && info !== 0) {
                        socket.emit('videoControl', { roomId:roomId, action:"seek", data:parseInt(info) });
                    }
                }
            };

                player.api('play', VideoUrl);


        };
        const handleVideoControl = (data) => {
            if (data) {
                if (data.action === "setUrl") {
                    setVideoUrl(data.data);
                    console.log(data.data);
                } else if (data.action === "play") {
                    player.api("play");
                } else if (data.action === "pause") {
                    player.api("pause");
                } else if (data.action === "seek") {
                    lockSeek = true;
                    if (Math.abs(player.api("time") - data.data) > 2) {
                        player.api("seek", data.data);
                    }
                    lockSeek = false;
                } else if (data.action === "sync") {
                    lockSeek = true;
                    if (Math.abs(player.api("time") - data.data) > 2) {
                        player.api("seek", data.data);
                    }
                    lockSeek = false;
                }
            }
        };

        socket.on('videoControl', handleVideoControl);

        return () => {
            if (player) {
                player.api('destroy');
            }
            document.body.removeChild(script);
            socket.off('videoControl', handleVideoControl);
        };

    }, [socket, VideoUrl]);

    return <div id="player" ref={playerRef} style={{ width: '100%', height: '100%' }} />;
};

export default Player;  код из iframe: this.addListener("seeking", (e) => {
                                    parent.postMessage({ type: 'seeking', time: e.target.currentTime }, '*');
                                });

                                this.addListener("play", (e) => {
                                    parent.postMessage({ type: 'play', time: e.target.currentTime }, '*');
                                });

                                this.addListener("pause", (e) => {
                                    parent.postMessage({ type: 'pause', time: e.target.currentTime }, '*');
                                });

                                this.addListener("playlistItem", (e) => {
                                    parent.postMessage({
                                        type: 'playlistItem',
                                        season: e.season,
                                        episode: e.episode
                                    }, '*');
                                });

                                window.addEventListener('message', (event) => {
                                    // Ensure the message is from a trusted source if necessary.
                                    // if (event.origin !== 'http://trusted_source.com') return;

                                    if (event.data === 'play') {
                                        this.play();
                                    } else if (event.data === 'pause') {
                                        this.pause();
                                    } else if (typeof event.data === 'object' && event.data.action === 'seek') {
                                        this.seek(0, event.data.time);
                                    } else if (typeof event.data === 'object' && event.data.action === 'changeEpisode') {
                                        this.changeEpisode({ season: event.data.season, episode: event.data.episode });
                                    }
                                });