Embed: mews: added subtitle support
This commit is contained in:
parent
431c06e4cd
commit
b6068f4627
4 changed files with 20 additions and 3 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1536,7 +1536,7 @@ MistSkins["default"] = {
|
||||||
for (var i in MistVideo.info.source) {
|
for (var i in MistVideo.info.source) {
|
||||||
var source = MistVideo.info.source[i];
|
var source = MistVideo.info.source[i];
|
||||||
//this is a subtitle source, and it's the same protocol (HTTP/HTTPS) as the video source
|
//this is a subtitle source, and it's the same protocol (HTTP/HTTPS) as the video source
|
||||||
if ((source.type == "html5/text/vtt") && (MistUtil.http.url.split(source.url).protocol == MistUtil.http.url.split(MistVideo.source.url).protocol)) {
|
if ((source.type == "html5/text/vtt") && (MistUtil.http.url.split(source.url).protocol == MistUtil.http.url.split(MistVideo.source.url).protocol.replace(/^ws/,"http"))) {
|
||||||
subtitleSource = source.url.replace(/.srt$/,".vtt");
|
subtitleSource = source.url.replace(/.srt$/,".vtt");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1021,6 +1021,23 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
});
|
});
|
||||||
player.ws.close();
|
player.ws.close();
|
||||||
|
},
|
||||||
|
setSubtitle: function(trackmeta) {
|
||||||
|
//remove previous subtitles
|
||||||
|
var tracks = video.getElementsByTagName("track");
|
||||||
|
for (var i = tracks.length - 1; i >= 0; i--) {
|
||||||
|
video.removeChild(tracks[i]);
|
||||||
|
}
|
||||||
|
if (trackmeta) { //if the chosen track exists
|
||||||
|
//add the new one
|
||||||
|
var track = document.createElement("track");
|
||||||
|
video.appendChild(track);
|
||||||
|
track.kind = "subtitles";
|
||||||
|
track.label = trackmeta.label;
|
||||||
|
track.srclang = trackmeta.lang;
|
||||||
|
track.src = trackmeta.src;
|
||||||
|
track.setAttribute("default","");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue