Adds the ability to play youtube videos.

It still needs a bit of work, but playing and pausing are operational.
This commit is contained in:
Markil3
2021-08-16 22:42:44 -06:00
parent b546c81fa1
commit ede9132279
23 changed files with 799 additions and 140 deletions

76
add-on/youtube.js Normal file
View File

@@ -0,0 +1,76 @@
console.debug("Loading youtube.js")
var video;
function onload()
{
video = document.getElementsByClassName('video-stream html5-main-video')[0]
}
function getState()
{
if (!video)
{
return 4;
}
else if (video.ended)
{
return 3;
}
else if (video.paused)
{
return 1;
}
else
{
return 0;
}
}
function getTime()
{
return video.currentTime;
}
function getLength()
{
return video.duration;
}
function play()
{
if (video != null)
{
video.play();
return true;
}
return false;
}
function pause()
{
if (video != null)
{
video.pause();
return true;
}
return false;
}
function seek(time)
{
if (video != null)
{
video.currentTime = time;
return true;
}
return false;
}
if (document.readyState === "complete")
{
onload();
}
else
{
window.addEventListener("load", onload);
}