Skip to content

Commit

Permalink
Merge pull request #195 from curiousyuvi/172-enhancement-use-random-g…
Browse files Browse the repository at this point in the history
…radient-images-for-room-thumbnails

keep iframe alive on tab switch
  • Loading branch information
curiousyuvi authored Mar 7, 2023
2 parents e9bb8af + 3767ea2 commit 5f379a5
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions client/components/YoutubeEmbedPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ import useRoomMusic from "../hooks/useRoomMusic";
import YouTube from "react-youtube";

const YoutubeEmbedPlayer = () => {
let requestId;
const debugEmbed = false;
const { setPlayer, setPaused, currentTrack, setProgress, setDuration } =
useRoomMusic();
const {
setPlayer,
setPaused,
currentTrack,
setProgress,
setDuration,
player,
} = useRoomMusic();

const handleStateChange = (event: any) => {
switch (event.data) {
switch (event?.data) {
case 1: {
setPaused(false);
const update = () => {
player?.getCurrentTime();
requestId = requestAnimationFrame(update);
};
requestId = requestAnimationFrame(update);
break;
}
default:
Expand All @@ -20,8 +32,14 @@ const YoutubeEmbedPlayer = () => {

const _onReady = (event: any) => {
setPlayer(event.target);
setDuration(event.target.getDuration());
setProgress(event.target.getCurrentTime());
setDuration(event.target?.getDuration());
setProgress(event.target?.getCurrentTime());

function update() {
event.target?.getCurrentTime();
requestId = requestAnimationFrame(update);
}
requestId = requestAnimationFrame(update);
};

const _onEnd = (event: any) => {
Expand Down

1 comment on commit 5f379a5

@vercel
Copy link

@vercel vercel bot commented on 5f379a5 Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

curie – ./

curie-xi.vercel.app
curie-git-main-curiousyuvi.vercel.app
curie-curiousyuvi.vercel.app

Please sign in to comment.