Hello everyone and Happy New Year!
I am developing a TinyMCE plugin and I have some Javascript code which works with Youtube Iframe API.
Initially, this code has been developed into a Moodle Page like the following:
HTML
<script src="https://www.youtube.com/iframe_api"></script>
<script>
Variables declaration
function onYouTubeIframeAPIReady() {
player = new YT.Player('videoPlayer', {
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
highlightCurrentTextAutomatically();
}
function onPlayerStateChange(event) {
if (event.data === YT.PlayerState.PAUSED) {
cancelAnimationFrame(updateRequest);
videoPlaying = false;
} else if (event.data === YT.PlayerState.PLAYING) {
highlightCurrentTextAutomatically();
videoPlaying = true;
}
}
other functions...
</script>
Without the API, the code can't work. How I can implement the API? I need to create a lib.php file?
Thank you!