add credentials to media elements

This commit is contained in:
Luke Pulverenti 2016-02-05 10:31:11 -05:00
parent e8b7d2e27e
commit 818ff90aff

View File

@ -178,7 +178,7 @@
html += '<div class="mediaPlayerAudioContainer" style="display:none;padding: 1em;background: #222;"><div class="mediaPlayerAudioContainerInner">';;
}
html += '<audio class="mediaPlayerAudio" crossorigin="use-credentials" controls>';
html += '<audio class="mediaPlayerAudio" controls>';
html += '</audio></div></div>';
$(document.body).append(html);
@ -211,6 +211,14 @@
return MediaPlayer.canPlayHls() && !MediaPlayer.canPlayNativeHls();
}
function getCrossOriginValue(mediaSource) {
if (mediaSource.EnableHttpCredentials) {
return 'use-credentials';
}
return 'anonymous';
}
function createVideoElement() {
var html = '';
@ -222,15 +230,15 @@
// Can't autoplay in these browsers so we need to use the full controls
if (requiresNativeControls && AppInfo.isNativeApp && browserInfo.android) {
html += '<video class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay" crossorigin="use-credentials"' + poster + ' webkit-playsinline>';
html += '<video class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay"' + poster + ' webkit-playsinline>';
}
else if (requiresNativeControls) {
html += '<video class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay" crossorigin="use-credentials"' + poster + ' controls="controls" webkit-playsinline>';
html += '<video class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay"' + poster + ' controls="controls" webkit-playsinline>';
}
else {
// Chrome 35 won't play with preload none
html += '<video class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay" crossorigin="use-credentials"' + poster + ' webkit-playsinline>';
html += '<video class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay"' + poster + ' webkit-playsinline>';
}
html += '</video>';
@ -350,6 +358,7 @@
return;
}
elem.crossOrigin = getCrossOriginValue(mediaSource);
var val = streamInfo.url;
if (AppInfo.isNativeApp && browserInfo.safari) {