update components

This commit is contained in:
Luke Pulverenti 2016-01-23 14:03:59 -05:00
parent 6ea653d815
commit 97286bc27a
33 changed files with 361 additions and 258 deletions

View file

@ -5,53 +5,6 @@ define(['browser'], function (browser) {
return !!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
}
var supportedFormats;
function getSupportedFormats() {
if (supportedFormats) {
return supportedFormats;
}
var list = [];
var elem = document.createElement('video');
if (elem.canPlayType('video/webm').replace(/no/, '')) {
list.push('webm');
}
if (elem.canPlayType('audio/mp4; codecs="ac-3"').replace(/no/, '')) {
list.push('ac3');
}
if (browser.chrome) {
list.push('mkv');
}
if (canPlayH264()) {
list.push('h264');
}
if (document.createElement('audio').canPlayType('audio/aac').replace(/no/, '') || browser.firefox) {
list.push('aac');
}
if (document.createElement('audio').canPlayType('audio/mp3').replace(/no/, '')) {
list.push('mp3');
}
if (document.createElement('audio').canPlayType('audio/ogg; codecs="opus"').replace(/no/, '')) {
list.push('opus');
}
if (document.createElement('audio').canPlayType('audio/webm').replace(/no/, '')) {
list.push('webma');
}
if (document.createElement('audio').canPlayType('audio/flac').replace(/no/, '')) {
list.push('flac');
}
supportedFormats = list;
return list;
}
var _supportsTextTracks;
function supportsTextTracks() {
@ -85,9 +38,28 @@ define(['browser'], function (browser) {
function canPlayHlsWithMSE() {
if (window.MediaSource != null) {
// text tracks dont work with this in firefox
return !browser.firefox;
}
// text tracks dont work with this in firefox
return !browser.firefox;
}
return false;
}
function canPlayAudioFormat(format) {
var typeString;
if (format == 'opus') {
typeString = 'audio/ogg; codecs="opus"';
} else if (format == 'webma') {
typeString = 'audio/webm';
} else {
typeString = 'audio/' + format;
}
if (document.createElement('audio').canPlayType(typeString).replace(/no/, '')) {
return true;
}
return false;
}
@ -96,13 +68,11 @@ define(['browser'], function (browser) {
var bitrateSetting = 100000000;
var supportedFormats = getSupportedFormats();
var videoTestElement = document.createElement('video');
var canPlayWebm = supportedFormats.indexOf('webm') != -1;
var canPlayAc3 = supportedFormats.indexOf('ac3') != -1;
var canPlayMp3 = supportedFormats.indexOf('mp3') != -1;
var canPlayAac = supportedFormats.indexOf('aac') != -1;
var canPlayMkv = supportedFormats.indexOf('mkv') != -1;
var canPlayWebm = videoTestElement.canPlayType('video/webm').replace(/no/, '');
// No real way to detect this, but it's too good to pass up
var canPlayMkv = browser.chrome;
var profile = {};
@ -117,23 +87,23 @@ define(['browser'], function (browser) {
// Only put mp3 first if mkv support is there
// Otherwise with HLS and mp3 audio we're seeing some browsers
if (canPlayMkv) {
if (canPlayMp3) {
if (canPlayAudioFormat('mp3')) {
videoAudioCodecs.push('mp3');
}
}
if (canPlayAac) {
if (canPlayAudioFormat('aac')) {
videoAudioCodecs.push('aac');
}
if (!canPlayMkv) {
if (canPlayMp3) {
if (canPlayAudioFormat('mp3')) {
videoAudioCodecs.push('mp3');
}
}
if (canPlayAc3) {
if (videoTestElement.canPlayType('audio/mp4; codecs="ac-3"').replace(/no/, '')) {
videoAudioCodecs.push('ac3');
}
if (supportedFormats.indexOf('h264') != -1) {
if (canPlayH264()) {
profile.DirectPlayProfiles.push({
Container: 'mp4,m4v',
Type: 'Video',
@ -151,14 +121,12 @@ define(['browser'], function (browser) {
});
}
['opus', 'mp3', 'aac', 'flac', 'webma'].forEach(function (audioFormat) {
['opus', 'mp3', 'aac', 'flac', 'webma'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
if (supportedFormats.indexOf(audioFormat) != -1) {
profile.DirectPlayProfiles.push({
Container: audioFormat == 'webma' ? 'webma,webm' : audioFormat,
Type: 'Audio'
});
}
profile.DirectPlayProfiles.push({
Container: audioFormat == 'webma' ? 'webma,webm' : audioFormat,
Type: 'Audio'
});
});
if (canPlayWebm) {
@ -170,24 +138,22 @@ define(['browser'], function (browser) {
profile.TranscodingProfiles = [];
['opus', 'mp3', 'aac'].forEach(function (audioFormat) {
['opus', 'mp3', 'aac'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
if (supportedFormats.indexOf(audioFormat) != -1) {
profile.TranscodingProfiles.push({
Container: audioFormat,
Type: 'Audio',
AudioCodec: audioFormat,
Context: 'Streaming',
Protocol: 'http'
});
profile.TranscodingProfiles.push({
Container: audioFormat,
Type: 'Audio',
AudioCodec: audioFormat,
Context: 'Static',
Protocol: 'http'
});
}
profile.TranscodingProfiles.push({
Container: audioFormat,
Type: 'Audio',
AudioCodec: audioFormat,
Context: 'Streaming',
Protocol: 'http'
});
profile.TranscodingProfiles.push({
Container: audioFormat,
Type: 'Audio',
AudioCodec: audioFormat,
Context: 'Static',
Protocol: 'http'
});
});
// Can't use mkv on mobile because we have to use the native player controls and they won't be able to seek it