Embed:
- fixes as a result of documentation, fixed secondaryVideo - added muted option, changing tracks sets options.setTracks - no positive values for startunix when live seeking - dashjs tracks updated, videojs display tweaked - fixes for track selection and live seeking
This commit is contained in:
parent
0a1b00cb5e
commit
998d7c6d03
22 changed files with 283 additions and 119 deletions
|
@ -103,6 +103,9 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
if (MistVideo.options.poster) {
|
||||
ele.setAttribute("poster",MistVideo.options.poster);
|
||||
}
|
||||
if (MistVideo.options.muted) {
|
||||
ele.muted = true;
|
||||
}
|
||||
if (MistVideo.options.controls == "stock") {
|
||||
ele.setAttribute("controls","");
|
||||
}
|
||||
|
@ -141,20 +144,34 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
}
|
||||
|
||||
//figure out what the track number is
|
||||
//whyyyy did it have to be reverse order
|
||||
var n = me.dash.getBitrateInfoListFor("video").length - 1;
|
||||
//for dash: 0 lowest bitrate, going up
|
||||
//get the relevant tracks
|
||||
var mistTracks = [];
|
||||
for (var i in MistVideo.info.meta.tracks) {
|
||||
var t = MistVideo.info.meta.tracks[i];
|
||||
if (t.type == type) {
|
||||
if (t.trackid == id) { break; }
|
||||
n--;
|
||||
mistTracks.push(t);
|
||||
}
|
||||
}
|
||||
//sort by bitrate
|
||||
MistUtil.array.multiSort(mistTracks,["bps"]);
|
||||
var n = false;
|
||||
for (var i in mistTracks) {
|
||||
if (mistTracks[i].trackid == id) {
|
||||
n = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (n === false) {
|
||||
return false; //track not found
|
||||
}
|
||||
|
||||
me.dash.setAutoSwitchQualityFor(type,false); //turn off ABR rules //TODO do we want this by default?
|
||||
me.dash.setFastSwitchEnabled(true); //show the new track asap
|
||||
me.dash.setQualityFor(type,n);
|
||||
//dash does change the track, but is appended to the buffer, so it seems to take a while..
|
||||
|
||||
return true; //track found and change requested
|
||||
}
|
||||
|
||||
//react to automatic trackswitching
|
||||
|
@ -162,19 +179,19 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
//the newQuality-th track of type mediaType is being selected
|
||||
|
||||
//figure out the track id
|
||||
//whyyyy did it have to be reverse order
|
||||
var n = me.dash.getBitrateInfoListFor("video").length - 1;
|
||||
var id;
|
||||
//for dash: 0 lowest bitrate, going up
|
||||
//get the relevant tracks
|
||||
var mistTracks = [];
|
||||
for (var i in MistVideo.info.meta.tracks) {
|
||||
var t = MistVideo.info.meta.tracks[i];
|
||||
if (t.type == e.mediaType) {
|
||||
if (e.newQuality == n) {
|
||||
id = t.trackid;
|
||||
break;
|
||||
}
|
||||
n--;
|
||||
mistTracks.push(t);
|
||||
}
|
||||
}
|
||||
//sort by bitrate
|
||||
MistUtil.array.multiSort(mistTracks,["bps"]);
|
||||
//get mist's id for the track
|
||||
var id = mistTracks[e.newQuality].trackid;
|
||||
|
||||
//create an event to pass this to the skin
|
||||
MistUtil.event.send("playerUpdate_trackChanged",{
|
||||
|
@ -183,6 +200,37 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
},MistVideo.video);
|
||||
|
||||
});
|
||||
var subsloaded = false;
|
||||
me.dash.on("allTextTracksAdded",function(){
|
||||
subsloaded = true;
|
||||
});
|
||||
|
||||
MistVideo.player.api.setSubtitle = function(trackmeta) {
|
||||
|
||||
if (!subsloaded) {
|
||||
var f = function(){
|
||||
MistVideo.player.api.setSubtitle(trackmeta);
|
||||
me.dash.off("allTextTracksAdded",f);
|
||||
};
|
||||
me.dash.on("allTextTracksAdded",f);
|
||||
return;
|
||||
}
|
||||
if (!trackmeta) {
|
||||
me.dash.enableText(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var dashsubs = me.dash.getTracksFor("text");
|
||||
for (var i in dashsubs) {
|
||||
if (dashsubs[i].id == trackmeta.trackid) {
|
||||
me.dash.setTextTrack(i);
|
||||
if (!me.dash.isTextEnabled()) { me.dash.enableText(); }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false; //failed to find subtitle
|
||||
};
|
||||
|
||||
//dashjs keeps on spamming the stalled icon >_>
|
||||
MistUtil.event.addListener(ele,"progress",function(e){
|
||||
|
|
|
@ -56,13 +56,22 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
|
||||
MistUtil.empty(ele);
|
||||
ele.appendChild(createParam("movie",MistVideo.urlappend(options.host+MistVideo.source.player_url)));
|
||||
var flashvars = "src="+encodeURIComponent(source)+"&controlBarMode="+(options.controls ? "floating" : "none")+"&initialBufferTime=0.5&expandedBufferTime=5&minContinuousPlaybackTime=3"+(options.live ? "&streamType=live" : "")+(options.autoplay ? "&autoPlay=true" : "" );
|
||||
var flashvars = "src="+encodeURIComponent(source)+"&controlBarMode="+(options.controls ? "floating" : "none")+"&initialBufferTime=0.5&expandedBufferTime=5&minContinuousPlaybackTime=3"+(options.live ? "&streamType=live" : "")+(options.autoplay ? "&autoPlay=true" : "" )+(options.loop ? "&loop=true" : "" )+(options.poster ? "&poster="+options.poster : "" )+(options.muted ? "&muted=true" : "" );
|
||||
ele.appendChild(createParam("flashvars",flashvars));
|
||||
ele.appendChild(createParam("allowFullScreen","true"));
|
||||
ele.appendChild(createParam("wmode","direct"));
|
||||
if (options.autoplay) {
|
||||
ele.appendChild(createParam("autoPlay","true"));
|
||||
}
|
||||
if (options.loop) {
|
||||
ele.appendChild(createParam("loop","true"));
|
||||
}
|
||||
if (options.poster) {
|
||||
ele.appendChild(createParam("poster",options.poster));
|
||||
}
|
||||
if (options.muted) {
|
||||
ele.appendChild(createParam("muted","true"));
|
||||
}
|
||||
|
||||
e.setAttribute("src",MistVideo.urlappend(MistVideo.source.player_url));
|
||||
e.setAttribute("type","application/x-shockwave-flash");
|
||||
|
|
|
@ -114,6 +114,9 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
video.setAttribute(attr,(MistVideo.options[attr] === true ? "" : MistVideo.options[attr]));
|
||||
}
|
||||
}
|
||||
if (MistVideo.options.muted) {
|
||||
video.muted = true; //don't use attribute because of Chrome bug: https://stackoverflow.com/questions/14111917/html5-video-muted-but-stilly-playing?rq=1
|
||||
}
|
||||
if (MistVideo.options.controls == "stock") {
|
||||
video.setAttribute("controls","");
|
||||
}
|
||||
|
@ -168,11 +171,19 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
};
|
||||
overrides.set.currentTime = function(value){
|
||||
var offset = value - MistVideo.player.api.duration;
|
||||
|
||||
if (offset > 0) {offset = 0;} //don't allow positive numbers, as Mist will interpret them as unix timestamps
|
||||
|
||||
MistVideo.player.api.liveOffset = offset;
|
||||
|
||||
MistVideo.log("Seeking to "+MistUtil.format.time(value)+" ("+Math.round(offset*-10)/10+"s from live)");
|
||||
|
||||
MistVideo.player.api.setSource(MistUtil.http.url.addParam(MistVideo.source.url,{startunix:offset}));
|
||||
var params = {startunix:offset};
|
||||
if (offset == 0) {
|
||||
params = {};
|
||||
}
|
||||
|
||||
MistVideo.player.api.setSource(MistUtil.http.url.addParam(MistVideo.source.url,params));
|
||||
}
|
||||
MistUtil.event.addListener(video,"progress",function(){
|
||||
MistVideo.player.api.lastProgress = new Date();
|
||||
|
|
|
@ -59,6 +59,10 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
vjsopts.loop = true;
|
||||
ele.loop = true;
|
||||
}
|
||||
if (MistVideo.options.muted) {
|
||||
vjsopts.muted = true;
|
||||
ele.muted = true;
|
||||
}
|
||||
if (MistVideo.options.poster) { vjsopts.poster = MistVideo.options.poster; }
|
||||
if (MistVideo.options.controls == "stock") {
|
||||
ele.setAttribute("controls","");
|
||||
|
@ -71,7 +75,6 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
me.onready(function(){
|
||||
me.videojs = videojs(ele,vjsopts,function(){
|
||||
MistVideo.log("Videojs initialized");
|
||||
|
|
|
@ -49,6 +49,9 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
video.setAttribute(attr,(MistVideo.options[attr] === true ? "" : MistVideo.options[attr]));
|
||||
}
|
||||
}
|
||||
if (MistVideo.options.muted) {
|
||||
video.muted = true; //don't use attribute because of Chrome bug
|
||||
}
|
||||
if (MistVideo.info.type == "live") {
|
||||
video.loop = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue