Skip to content Skip to sidebar Skip to footer

Switching Audiotrack On Chromecast

I actually cannot believe I couldn't find an answer to this as it appears to me as if it should be a common problem - am I using the wrong terminology? However, I am looking for a

Solution 1:

Look at the media player library documentation for cycling through audio streams: https://developers.google.com/cast/docs/player

window.changeLanguage = function() {
 var currentLanguage = null;
 var streamCount = this.protocol_.getStreamCount();
 var streamInfo;
 for (var i = 0; i < streamCount; i++) {
   if (protocol.isStreamEnabled(i)) {
     streamInfo = protocol.getStreamInfo(i);
     if (streamInfo.mimeType.indexOf('audio') === 0) {
       if (streamInfo.language) {
         currentLanguage = i;
         break;
       }
     }
   }
 }

 if (currentLanguage === null) {
   currentLanguage = 0;
 }

 i = currentLanguage + 1;
 while (i !== currentLanguage) {
   if (i === streamCount) {
     i = 0;
   }

   streamInfo = protocol.getStreamInfo(i);
   if (streamInfo.mimeType.indexOf('audio') === 0) {
     protocol.enableStream(i, true);
     protocol.enableStream(currentLanguage, false);
     break;
   }

   i++;
 }

 if (i !== currentLanguage) {
   this.player_.reload();
 }
};

Post a Comment for "Switching Audiotrack On Chromecast"