Implement HTML5 hack for google drive
Requires enabling in config.yaml google-drive: html5-hack-enabled: true Requires a recent version of node and an IPv6 address EXPERIMENTAL
This commit is contained in:
parent
d9d385f85e
commit
af663bfbcf
|
@ -30,6 +30,14 @@ window.loadMediaPlayer = (data) ->
|
||||||
window.PLAYER = new VideoJSPlayer(data)
|
window.PLAYER = new VideoJSPlayer(data)
|
||||||
catch e
|
catch e
|
||||||
console.error e
|
console.error e
|
||||||
|
else if data.type is 'gd'
|
||||||
|
try
|
||||||
|
if data.meta.html5hack
|
||||||
|
window.PLAYER = new VideoJSPlayer(data)
|
||||||
|
else
|
||||||
|
window.PLAYER = new GoogleDriveYouTubePlayer(data)
|
||||||
|
catch e
|
||||||
|
console.error e
|
||||||
else if data.type of TYPE_MAP
|
else if data.type of TYPE_MAP
|
||||||
try
|
try
|
||||||
window.PLAYER = TYPE_MAP[data.type](data)
|
window.PLAYER = TYPE_MAP[data.type](data)
|
||||||
|
|
|
@ -114,12 +114,13 @@ window.VideoJSPlayer = class VideoJSPlayer extends Player
|
||||||
# not to run until the ready() function returns.
|
# not to run until the ready() function returns.
|
||||||
setTimeout(->
|
setTimeout(->
|
||||||
$('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each((i, elem) ->
|
$('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each((i, elem) ->
|
||||||
if elem.textContent == localStorage.lastSubtitle
|
textNode = elem.childNodes[0]
|
||||||
|
if textNode.textContent == localStorage.lastSubtitle
|
||||||
elem.click()
|
elem.click()
|
||||||
|
|
||||||
elem.onclick = ->
|
elem.onclick = ->
|
||||||
if elem.attributes['aria-selected'].value == 'true'
|
if elem.attributes['aria-checked'].value == 'true'
|
||||||
localStorage.lastSubtitle = elem.textContent
|
localStorage.lastSubtitle = textNode.textContent
|
||||||
)
|
)
|
||||||
, 1)
|
, 1)
|
||||||
)
|
)
|
||||||
|
|
|
@ -120,6 +120,9 @@ var defaults = {
|
||||||
"service-socket": {
|
"service-socket": {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
socket: "service.sock"
|
socket: "service.sock"
|
||||||
|
},
|
||||||
|
"google-drive": {
|
||||||
|
"html5-hack-enabled": false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ var YouTube = require("cytube-mediaquery/lib/provider/youtube");
|
||||||
var Vimeo = require("cytube-mediaquery/lib/provider/vimeo");
|
var Vimeo = require("cytube-mediaquery/lib/provider/vimeo");
|
||||||
var Vidme = require("cytube-mediaquery/lib/provider/vidme");
|
var Vidme = require("cytube-mediaquery/lib/provider/vidme");
|
||||||
var Streamable = require("cytube-mediaquery/lib/provider/streamable");
|
var Streamable = require("cytube-mediaquery/lib/provider/streamable");
|
||||||
|
require("cytube-mediaquery/lib/provider/googledrive").setHTML5HackEnabled(
|
||||||
|
Config.get("google-drive.html5-hack-enabled"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Preference map of quality => youtube formats.
|
* Preference map of quality => youtube formats.
|
||||||
|
|
|
@ -38,7 +38,8 @@ Media.prototype = {
|
||||||
bitrate: this.meta.bitrate,
|
bitrate: this.meta.bitrate,
|
||||||
scuri: this.meta.scuri,
|
scuri: this.meta.scuri,
|
||||||
embed: this.meta.embed,
|
embed: this.meta.embed,
|
||||||
gdrive_subtitles: this.meta.gdrive_subtitles
|
gdrive_subtitles: this.meta.gdrive_subtitles,
|
||||||
|
html5hack: this.meta.html5hack
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -572,12 +572,14 @@
|
||||||
});
|
});
|
||||||
return setTimeout(function() {
|
return setTimeout(function() {
|
||||||
return $('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each(function(i, elem) {
|
return $('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each(function(i, elem) {
|
||||||
if (elem.textContent === localStorage.lastSubtitle) {
|
var textNode;
|
||||||
|
textNode = elem.childNodes[0];
|
||||||
|
if (textNode.textContent === localStorage.lastSubtitle) {
|
||||||
elem.click();
|
elem.click();
|
||||||
}
|
}
|
||||||
return elem.onclick = function() {
|
return elem.onclick = function() {
|
||||||
if (elem.attributes['aria-selected'].value === 'true') {
|
if (elem.attributes['aria-checked'].value === 'true') {
|
||||||
return localStorage.lastSubtitle = elem.textContent;
|
return localStorage.lastSubtitle = textNode.textContent;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -1310,7 +1312,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
window.loadMediaPlayer = function(data) {
|
window.loadMediaPlayer = function(data) {
|
||||||
var e, error, error1, error2, error3;
|
var e, error, error1, error2, error3, error4;
|
||||||
try {
|
try {
|
||||||
if (window.PLAYER) {
|
if (window.PLAYER) {
|
||||||
window.PLAYER.destroy();
|
window.PLAYER.destroy();
|
||||||
|
@ -1326,11 +1328,22 @@
|
||||||
e = error2;
|
e = error2;
|
||||||
return console.error(e);
|
return console.error(e);
|
||||||
}
|
}
|
||||||
|
} else if (data.type === 'gd') {
|
||||||
|
try {
|
||||||
|
if (data.meta.html5hack) {
|
||||||
|
return window.PLAYER = new VideoJSPlayer(data);
|
||||||
|
} else {
|
||||||
|
return window.PLAYER = new GoogleDriveYouTubePlayer(data);
|
||||||
|
}
|
||||||
|
} catch (error3) {
|
||||||
|
e = error3;
|
||||||
|
return console.error(e);
|
||||||
|
}
|
||||||
} else if (data.type in TYPE_MAP) {
|
} else if (data.type in TYPE_MAP) {
|
||||||
try {
|
try {
|
||||||
return window.PLAYER = TYPE_MAP[data.type](data);
|
return window.PLAYER = TYPE_MAP[data.type](data);
|
||||||
} catch (error3) {
|
} catch (error4) {
|
||||||
e = error3;
|
e = error4;
|
||||||
return console.error(e);
|
return console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue