html5 video change audiotrack function

61 Views Asked by At

i have build smart tv app use html5 player tag to play video streams some streams have few audio tracks

i have make this way:

<video id="video" ></video>

Player.playVideo = function()
{
var video = document.getElementById("video");
video.src = url;
video.autoplay = true;
video.load();   
video.play();           
}

to change audio track i use this simple function:

Player.audio = function()
{
var audioTracks = document.querySelector("video").audioTracks;
if ( audioTracks[1].enabled == false){
audioTracks[0].enabled = false;
audioTracks[1].enabled = true;
}else if ( audioTracks[0].enabled == false){ 
audioTracks[1].enabled = false;
audioTracks[0].enabled = true;
}
}

and this work on LG webos Smart tv what use firefox, but not work on other cheap smart tv what use Opera browser

please advise what best way to change audio tracks

Thanks

0

There are 0 best solutions below