Embed: changed track naming to only list the difference, or a number if all have equal meta

This commit is contained in:
Cat 2017-11-02 13:29:38 +01:00 committed by Thulinma
parent e75ae50c0c
commit ba11c868c9

View file

@ -1148,23 +1148,29 @@ function mistPlay(streamName,options) {
var skip = false; var skip = false;
switch (t.type) { switch (t.type) {
case 'video': case 'video':
t.desc = [t.width+'x'+t.height,Math.round(t.bps/1024)+'kbps',t.fpks/1e3+'fps',t.codec]; t.desc = [
if (t.lang) { ("lang" in t ? t.language : "unknown"),
t.desc.unshift(t.language); t.width+'x'+t.height,
} (t.bps == 0 ? "unknown": (t.bps > 1024*1024/8 ? Math.round(t.bps/1024/1024*8)+'mbps': Math.round(t.bps/1024*8)+'kbps')),
(t.fpks == 0 ? "unknown" : t.fpks/1e3+'fps'),
t.codec
];
break; break;
case 'audio': case 'audio':
t.desc = [(t.channels == 2 ? 'Stereo' : (t.channels == 1 ? 'Mono' : t.channels+' channels')),Math.round(t.bps/1024)+'kbps',Math.round(t.rate/1000)+'kHz',t.codec]; t.desc = [
if (t.lang) { ("lang" in t ? t.language : "unknown"),
t.desc.unshift(t.language); (t.channels == 2 ? 'Stereo' : (t.channels == 1 ? 'Mono' : "Surround ("+t.channels+'ch)')),
} (t.bps == 0 ? "unknown": (t.bps > 1024*1024/8 ? Math.round(t.bps/1024/1024*8)+'mbps': Math.round(t.bps/1024*8)+'kbps')),
Math.round(t.rate/1000)+'kHz',
t.codec
];
break; break;
case 'meta': case 'meta':
case 'subtitle': case 'subtitle':
//subtitles are type meta and codec subtitle in Mist > v2.13, still support type subtitle though //subtitles are type meta and codec subtitle in Mist > v2.13, still support type subtitle though
if ((t.type == 'subtitle') || (t.codec == 'subtitle')) { if ((t.type == 'subtitle') || (t.codec == 'subtitle')) {
t.type = "subtitle"; t.type = "subtitle";
t.desc = [t.language]; t.desc = [("lang" in t ? t.language : "unknown")];
break; break;
} }
default: default:
@ -1172,9 +1178,64 @@ function mistPlay(streamName,options) {
break; break;
} }
if (skip) { continue; } if (skip) { continue; }
t.desc = t.desc.join(' ');
tracks[t.type].push(t); tracks[t.type].push(t);
} }
//loop through the tracks again and compare them to one another to decide what to display as description
for (var cat in tracks) {
if (tracks[cat].length == 1) {
//there is only one track, show all info that isn't "unknown"
for (var i in tracks[cat]) {
var t = tracks[cat][i];
for (var j = t.desc.length-1; j >= 0; j--) {
if ((t.desc[j] == "unknown") && (t.desc.length > 1)) {
t.desc.splice(j,1);
}
}
t.desc = t.desc.join(" ");
}
}
else {
var equal = false;
var show = [];
//sort by track id
tracks[cat].sort(function(a,b){
return a.trackid - b.trackid;
});
for (var i in tracks[cat]) {
var t = tracks[cat][i];
if (equal == false) {
//set equal to the first track description
equal = t.desc;
continue;
}
for (var j in t.desc) {
//compare each value to the one in equal, if it's not the same, mark it
if ((t.desc[j] != equal[j]) && (show.indexOf(j) < 0)) {
show.push(j);
}
}
}
if (show.length) {
for (var i in tracks[cat]) {
var t = tracks[cat][i];
//gather indexes in show
var str = [];
for (var j in show) {
str.push(t.desc[show[j]]);
}
t.desc = str.join(" ");
}
}
else {
//all info is the same, show a track index
for (var i in tracks[cat]) {
var t = tracks[cat][i];
t.desc = "Track "+(Number(i)+1);
}
}
}
}
player.tracks = tracks; player.tracks = tracks;
if (tracks.subtitle.length) { if (tracks.subtitle.length) {
var vttsrc = false; var vttsrc = false;