This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as VideoYT from "./videoYT.js"; | |
VideoYT.loadVideoById(localVars.iframeId, localVars.videoId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getCurrentTime(iframeId) { | |
return Globals.ytPlayer[iframeId]["player"].getCurrentTime(); | |
} | |
export function getDuration(iframeId) { | |
return Globals.ytPlayer[iframeId]["player"].getDuration(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function loadPlaylist(iframeId, videoId) { | |
Globals.ytPlayer[iframeId]["player"].loadPlaylist(Globals.playlist[videoId]); | |
} | |
export function lengthPlaylist(iframeId) { | |
return Globals.ytPlayer[iframeId]["player"].getPlaylist().length; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function loadVideoById(iframeId, videoId) { | |
Globals.ytPlayer[iframeId]["player"].loadVideoById(videoId); | |
} | |
export function loadVideoByUrl(iframeId, videoId) { | |
Globals.ytPlayer[iframeId]["player"].loadVideoByUrl(videoId); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function cueVideoById(iframeId, videoId) { | |
Globals.ytPlayer[iframeId]["player"].cueVideoById(videoId); | |
} | |
export function cueVideoByUrl(iframeId, videoId) { | |
Globals.ytPlayer[iframeId]["player"].cueVideoByUrl(videoId); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function setVolume(iframeId, volume) { | |
Globals.ytPlayer[iframeId]["player"].setVolume(volume); | |
} | |
export function getVolume(iframeId) { | |
return Globals.ytPlayer[iframeId]["player"].getVolume(); | |
} | |
export function mute(iframeId) { | |
Globals.ytPlayer[iframeId]["player"].mute(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function playVideo(iframeId) { | |
Globals.ytPlayer[iframeId]["player"].playVideo(); | |
} | |
export function pauseVideo(iframeId) { | |
Globals.ytPlayer[iframeId]["player"].pauseVideo(); | |
} | |
export function stopVideo(iframeId) { | |
Globals.ytPlayer[iframeId]["player"].stopVideo(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const Globals = { | |
ytPlayer: {}, | |
}; | |
export function initializeVideo(iframeId) { | |
Globals.ytPlayer[iframeId] = {}; | |
Globals.ytPlayer[iframeId]["player"] = null; | |
} | |
export async function createVideo(iframeId) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as YouTube from "./youTube.js"; | |
export async function createVideo(iframeId) { | |
Globals.ytPlayer[iframeId]["player"] = await YouTube.CreatePlayer(iframeId, { | |
onStateChange: (e) => { | |
console.log(e.data); | |
}, | |
onReady: (e) => { | |
console.log(e); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function CreatePlayer(iframeId, eventHandlers) { | |
return new Promise((resolve) => { | |
if (!eventHandlers) eventHandlers = {}; | |
eventHandlers["onReady"] = (e) => resolve(e.target); | |
eventHandlers["onPlayerStateChange"] = (e) => resolve(e.target); | |
new globalThis["YT"]["Player"](iframeId, { | |
events: eventHandlers, | |
}); |