mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Add support for multi-audio language videos.
This commit is contained in:
parent
0e042244e8
commit
5a268b26bd
2 changed files with 51 additions and 27 deletions
|
@ -440,7 +440,14 @@ export default {
|
||||||
|
|
||||||
this.$ui = new shaka.ui.Overlay(localPlayer, this.$refs.container, videoEl);
|
this.$ui = new shaka.ui.Overlay(localPlayer, this.$refs.container, videoEl);
|
||||||
|
|
||||||
const overflowMenuButtons = ["quality", "captions", "picture_in_picture", "playback_rate", "airplay"];
|
const overflowMenuButtons = [
|
||||||
|
"quality",
|
||||||
|
"language",
|
||||||
|
"captions",
|
||||||
|
"picture_in_picture",
|
||||||
|
"playback_rate",
|
||||||
|
"airplay",
|
||||||
|
];
|
||||||
|
|
||||||
if (this.isEmbed) {
|
if (this.isEmbed) {
|
||||||
overflowMenuButtons.push("open_new_tab");
|
overflowMenuButtons.push("open_new_tab");
|
||||||
|
@ -480,6 +487,9 @@ export default {
|
||||||
if (qualityConds) this.$player.configure("abr.enabled", false);
|
if (qualityConds) this.$player.configure("abr.enabled", false);
|
||||||
|
|
||||||
player.load(uri, 0, mime).then(() => {
|
player.load(uri, 0, mime).then(() => {
|
||||||
|
// Set the audio language
|
||||||
|
player.selectAudioLanguage(this.getPreferenceString("hl", "en").substr(0, 2));
|
||||||
|
|
||||||
if (qualityConds) {
|
if (qualityConds) {
|
||||||
var leastDiff = Number.MAX_VALUE;
|
var leastDiff = Number.MAX_VALUE;
|
||||||
var bestStream = null;
|
var bestStream = null;
|
||||||
|
|
|
@ -42,55 +42,69 @@ const DashUtils = {
|
||||||
},
|
},
|
||||||
generate_adaptation_set(VideoFormatArray) {
|
generate_adaptation_set(VideoFormatArray) {
|
||||||
const adaptationSets = [];
|
const adaptationSets = [];
|
||||||
const mimeTypes = [];
|
|
||||||
const mimeObjects = [[]];
|
let mimeAudioObjs = [];
|
||||||
// sort the formats by mime types
|
|
||||||
VideoFormatArray.forEach(videoFormat => {
|
VideoFormatArray.forEach(videoFormat => {
|
||||||
// the dual formats should not be used
|
// the dual formats should not be used
|
||||||
if (videoFormat.mimeType.indexOf("video") != -1 && !videoFormat.videoOnly) {
|
if (videoFormat.mimeType.indexOf("video") != -1 && !videoFormat.videoOnly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if these properties are not available, then we skip it because we cannot set these properties
|
|
||||||
//if (!(videoFormat.hasOwnProperty('initRange') && videoFormat.hasOwnProperty('indexRange'))) {
|
const audioTrackId = videoFormat.audioTrackId;
|
||||||
// return
|
|
||||||
//}
|
|
||||||
const mimeType = videoFormat.mimeType;
|
const mimeType = videoFormat.mimeType;
|
||||||
const mimeTypeIndex = mimeTypes.indexOf(mimeType);
|
|
||||||
if (mimeTypeIndex > -1) {
|
for (let i = 0; i < mimeAudioObjs.length; i++) {
|
||||||
mimeObjects[mimeTypeIndex].push(videoFormat);
|
const mimeAudioObj = mimeAudioObjs[i];
|
||||||
} else {
|
|
||||||
mimeTypes.push(mimeType);
|
if (mimeAudioObj.audioTrackId == audioTrackId && mimeAudioObj.mimeType == mimeType) {
|
||||||
mimeObjects.push([]);
|
mimeAudioObj.videoFormats.push(videoFormat);
|
||||||
mimeObjects[mimeTypes.length - 1].push(videoFormat);
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mimeAudioObjs.push({
|
||||||
|
audioTrackId,
|
||||||
|
mimeType,
|
||||||
|
videoFormats: [videoFormat],
|
||||||
});
|
});
|
||||||
// for each MimeType generate a new Adaptation set with Representations as sub elements
|
});
|
||||||
for (let i = 0; i < mimeTypes.length; i++) {
|
|
||||||
let isVideoFormat = false;
|
mimeAudioObjs.forEach(mimeAudioObj => {
|
||||||
const adapSet = {
|
const adapSet = {
|
||||||
type: "element",
|
type: "element",
|
||||||
name: "AdaptationSet",
|
name: "AdaptationSet",
|
||||||
attributes: {
|
attributes: {
|
||||||
id: i,
|
id: mimeAudioObj.audioTrackId,
|
||||||
mimeType: mimeTypes[i],
|
lang: mimeAudioObj.audioTrackId?.substr(0, 2),
|
||||||
|
mimeType: mimeAudioObj.mimeType,
|
||||||
startWithSAP: "1",
|
startWithSAP: "1",
|
||||||
subsegmentAlignment: "true",
|
subsegmentAlignment: "true",
|
||||||
},
|
},
|
||||||
elements: [],
|
elements: [],
|
||||||
};
|
};
|
||||||
if (!mimeTypes[i].includes("audio")) {
|
|
||||||
adapSet.attributes.scanType = "progressive";
|
let isVideoFormat = false;
|
||||||
|
|
||||||
|
if (mimeAudioObj.mimeType.includes("video")) {
|
||||||
isVideoFormat = true;
|
isVideoFormat = true;
|
||||||
}
|
}
|
||||||
mimeObjects[i].forEach(format => {
|
|
||||||
if (isVideoFormat) {
|
if (isVideoFormat) {
|
||||||
adapSet.elements.push(this.generate_representation_video(format));
|
adapSet.attributes.scanType = "progressive";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < mimeAudioObj.videoFormats.length; i++) {
|
||||||
|
const videoFormat = mimeAudioObj.videoFormats[i];
|
||||||
|
if (isVideoFormat) {
|
||||||
|
adapSet.elements.push(this.generate_representation_video(videoFormat));
|
||||||
} else {
|
} else {
|
||||||
adapSet.elements.push(this.generate_representation_audio(format));
|
adapSet.elements.push(this.generate_representation_audio(videoFormat));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
adaptationSets.push(adapSet);
|
adaptationSets.push(adapSet);
|
||||||
}
|
});
|
||||||
return adaptationSets;
|
return adaptationSets;
|
||||||
},
|
},
|
||||||
generate_representation_audio(Format) {
|
generate_representation_audio(Format) {
|
||||||
|
|
Loading…
Reference in a new issue