* fixes undefined videoFormat with forced stream id
parent
d386a55bad
commit
7ca97901ee
|
@ -2,7 +2,7 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
const video = document.getElementById('player_video');
|
||||
const audio = document.getElementById('player_audio');
|
||||
|
||||
const formats = JSON.parse(document.getElementById('yt_formats').innerText)
|
||||
formats = JSON.parse(document.getElementById('yt_formats').innerText)
|
||||
.filter((fmt) => isFormatSupported(fmt) === true)
|
||||
.sort((a, b) => {
|
||||
if (a.vcodec === 'none' && b.vcodec !== 'none') {
|
||||
|
@ -23,17 +23,21 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
if (localStorage.getItem("videoStream") == null) {
|
||||
const videoFormat = formats.find((fmt) => fmt.vcodec !== 'none');
|
||||
const audioFormat = videoFormat.acodec === 'none' ? formats.find((fmt) => fmt.acodec !== 'none') : null;
|
||||
console.log('aaaaaaaaaaaaaaa')
|
||||
console.log('selected video format', videoFormat);
|
||||
console.log('selected audio format', audioFormat);
|
||||
|
||||
selectStreams(videoFormat, audioFormat)
|
||||
} else {
|
||||
const videoFormat = formats.find((fmt) => fmt.format_id == localStorage.getItem("videoStream"));
|
||||
let videoFormat = formats.find((fmt) => fmt.format_id == localStorage.getItem("videoStream"));
|
||||
if (videoFormat == null) {
|
||||
videoFormat = formats.find((fmt) => fmt.vcodec !== 'none');
|
||||
}
|
||||
const audioFormat = videoFormat.acodec === 'none' ? formats.find((fmt) => fmt.format_id == localStorage.getItem("audioStream")) : null;
|
||||
if (audioFormat == null) {
|
||||
audioFormat = videoFormat.acodec === 'none' ? formats.find((fmt) => fmt.acodec !== 'none') : null;
|
||||
}
|
||||
console.log('selected video format', videoFormat);
|
||||
console.log('selected audio format', audioFormat);
|
||||
|
||||
|
||||
selectStreams(videoFormat, audioFormat)
|
||||
}
|
||||
|
@ -160,15 +164,17 @@ window.addEventListener('DOMContentLoaded', (event) => {
|
|||
function applyStreams() {
|
||||
let videoStreamInput = document.querySelector('#videoStreamInput');
|
||||
let audioStreamInput = document.querySelector('#audioStreamInput');
|
||||
localStorage.setItem("videoStream", parseInt(videoStreamInput.value));
|
||||
localStorage.setItem("audioStream", parseInt(audioStreamInput.value));
|
||||
localStorage.setItem("videoStream", videoStreamInput.value);
|
||||
localStorage.setItem("audioStream", audioStreamInput.value);
|
||||
|
||||
|
||||
const videoFormat = formats.find((fmt) => fmt.format_id == videoStreamInput.value);
|
||||
const audioFormat = videoFormat.acodec === 'none' ? formats.find((fmt) => fmt.format_id == audioStreamInput.value) : null;
|
||||
selectStreams(videoFormat, audioFormat)
|
||||
}
|
||||
|
||||
function resetStreams() {
|
||||
localStorage.setItem("videoStream", null);
|
||||
localStorage.setItem("audioStream", null);
|
||||
localStorage.removeItem("videoStream");
|
||||
localStorage.removeItem("audioStream");
|
||||
}
|
||||
|
||||
function getMimeType(fmt) {
|
||||
|
|
Loading…
Reference in New Issue