Я написал код JavaScript, который изменяет разрешение видео на основе ввода параметра/элемента выбора. Оно работает. Проблема в том, что он перестает работать, когда я помещаю в функцию один и тот же код (чтобы код мог выполняться несколько раз - каждый раз при изменении опции/элемента выбора.)
Вот изображение видеоплеера и добавленный мной элемент опции/выбора
Вот код для элемента опции/выбора:
Код: Выделить всё
[*]
Videokvalitet
HD 1080
SD 480
SD 320
Код: Выделить всё
Your browser does not support HTML5 video.
Your browser does not support HTML5 video.
Your browser does not support HTML5 video.
Код: Выделить всё
function changeVidQualityFunction(){
$chosenVidQuality = document.getElementById("selectQuality").value;
$trulycompletevideolink = document.getElementById("video1").src;
$step1 = document.getElementById("video1").src.split("_q_");
//COMMENT: step1[0] is the url from start and including the first part of the filename (not the "_q_"-part and the format)
$upToVidName = $step1[0];
//COMMENT: step1[1] is the resolution and format, e.g. 320.ogg
$step2 = $step1[1].split(".");
//COMMENT: step2[0] is the resoltion e.g. 720 ,step2[1] is the format (without the dot in front of the format type) e.g. ogg
$vidresolution = $step2[0];
$vidformat = $step2[1];
$vidresolution = $chosenVidQuality;
$result = $upToVidName+"_q_"+$vidresolution+"."+$vidformat;
$('#video1').attr('src', $result);
$('#video1V').attr('data-caption', $vidresolution+" OGG");
$('#video1V').load();
window.alert("video1 attr src:"+document.getElementById("video1").src); //shows updated URL
}
Подробнее здесь: https://stackoverflow.com/questions/389 ... javascript
Мобильная версия