[READ-ONLY] Mirror of https://github.com/flo-bit/youtube-party-dj. democratic youtube player, everyone can vote and add songs, uni project, made with uix
0

Configure Feed

Select the types of activity you want to include in your feed.

Update VideoPlayer.tsx

author
moritzbarv
committer
GitHub
date (Jun 14, 2024, 12:04 PM +0200) commit 6bac722d parent 15752a10
+52
+52
common/components/VideoPlayer.tsx
··· 79 79 </div> 80 80 ); 81 81 } 82 + 83 + 84 + /* 85 + let ytplayer; 86 + let spotplayer; 87 + const script = document.createElement("script"); 88 + script.src = "https://sdk.scdn.co/spotify-player.js"; 89 + script.async = true; 90 + document.body.appendChild(script); 91 + function play2(id: string, type: string) { 92 + if (type === "youtube") { 93 + if (ytplayer) { 94 + player.loadVideoById(id); 95 + } else { 96 + player = new window.YT.Player("ytplayer", { 97 + height: "315", 98 + width: "560", 99 + videoId: id, 100 + events: { 101 + onStateChange: onStateChange, 102 + }, 103 + playerVars: { 104 + autoplay: 1, 105 + color: "white", 106 + controls: 0, 107 + disablekb: 1, 108 + iv_load_policy: 3, 109 + modestbranding: 1, 110 + rel: 0, 111 + showinfo: 0, 112 + }, 113 + }); 114 + } 115 + } else if (type === "spotify") { 116 + if (spotplayer) { 117 + fetch(`https://api.spotify.com/v1/me/player/play`, { 118 + method: "PUT", 119 + body: JSON.stringify({ uris: [`spotify:track:${id}`] }), 120 + headers: { 121 + "Content-Type": "application/json", 122 + Authorization: `Bearer ${accessToken}`, 123 + }, 124 + }) else { 125 + player = new Spotify.Player({ 126 + name: 'Web Playback SDK', 127 + getOAuthToken: cb => { cb(accessToken); }, 128 + volume: 0.5 129 + }) 130 + }}; 131 + } 132 + } 133 + */