update components

This commit is contained in:
Luke Pulverenti 2016-01-06 11:38:19 -05:00
parent 46ceec311d
commit 89c9a7b669
38 changed files with 1530 additions and 316 deletions

View file

@ -15,12 +15,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.0.6",
"_release": "1.0.6",
"version": "1.0.14",
"_release": "1.0.14",
"_resolution": {
"type": "version",
"tag": "1.0.6",
"commit": "4d04f0ed205e94c00160c48dc131b9d8dbed995f"
"tag": "1.0.14",
"commit": "a7a8baf260ab509c5f9b1750cbf6fe921883141c"
},
"_source": "git://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "~1.0.0",

View file

@ -1,5 +1,10 @@
define(['browser'], function (browser) {
function canPlayH264() {
var v = document.createElement('video');
return !!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
}
var supportedFormats;
function getSupportedFormats() {
@ -20,13 +25,7 @@
list.push('mkv');
}
var canPlayH264 = true;
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf('firefox') != -1 && userAgent.indexOf('windows') == -1) {
canPlayH264 = false;
}
if (canPlayH264) {
if (canPlayH264()) {
list.push('h264');
}
@ -113,7 +112,7 @@
});
}
if (browser.chrome) {
if (canPlayMkv) {
profile.DirectPlayProfiles.push({
Container: 'mkv,mov',
Type: 'Video',
@ -161,12 +160,23 @@
}
});
var videoAudioCodecs = [];
if (canPlayMp3) {
videoAudioCodecs.push('mp3');
}
if (canPlayAac) {
videoAudioCodecs.push('aac');
}
if (canPlayAc3) {
videoAudioCodecs.push('ac3');
}
// Can't use mkv on mobile because we have to use the native player controls and they won't be able to seek it
if (canPlayMkv && !browser.mobile) {
profile.TranscodingProfiles.push({
Container: 'mkv',
Type: 'Video',
AudioCodec: 'aac' + (canPlayAc3 ? ',ac3' : ''),
AudioCodec: videoAudioCodecs.join(','),
VideoCodec: 'h264',
Context: 'Streaming'
});
@ -176,7 +186,7 @@
profile.TranscodingProfiles.push({
Container: 'ts',
Type: 'Video',
AudioCodec: 'aac' + (canPlayAc3 ? ',ac3' : ''),
AudioCodec: videoAudioCodecs.join(','),
VideoCodec: 'h264',
Context: 'Streaming',
Protocol: 'hls'
@ -198,7 +208,7 @@
profile.TranscodingProfiles.push({
Container: 'mp4',
Type: 'Video',
AudioCodec: 'aac',
AudioCodec: videoAudioCodecs.join(','),
VideoCodec: 'h264',
Context: 'Streaming',
Protocol: 'http'
@ -207,7 +217,7 @@
profile.TranscodingProfiles.push({
Container: 'mp4',
Type: 'Video',
AudioCodec: 'aac',
AudioCodec: videoAudioCodecs.join(','),
VideoCodec: 'h264',
Context: 'Static',
Protocol: 'http'

View file

@ -0,0 +1,129 @@
define([], function () {
function getFetchPromise(request) {
var headers = request.headers || {};
if (request.dataType == 'json') {
headers.accept = 'application/json';
}
var fetchRequest = {
headers: headers,
method: request.type,
credentials: 'same-origin'
};
var contentType = request.contentType;
if (request.data) {
if (typeof request.data === 'string') {
fetchRequest.body = request.data;
} else {
fetchRequest.body = paramsToString(request.data);
contentType = contentType || 'application/x-www-form-urlencoded; charset=UTF-8';
}
}
if (contentType) {
headers['Content-Type'] = contentType;
}
var url = request.url;
if (request.query) {
var paramString = paramsToString(request.query);
if (paramString) {
url += '?' + paramString;
}
}
if (!request.timeout) {
return fetch(url, fetchRequest);
}
return fetchWithTimeout(url, fetchRequest, request.timeout);
}
function fetchWithTimeout(url, options, timeoutMs) {
console.log('fetchWithTimeout: timeoutMs: ' + timeoutMs + ', url: ' + url);
return new Promise(function (resolve, reject) {
var timeout = setTimeout(reject, timeoutMs);
options = options || {};
options.credentials = 'same-origin';
fetch(url, options).then(function (response) {
clearTimeout(timeout);
console.log('fetchWithTimeout: succeeded connecting to url: ' + url);
resolve(response);
}, function (error) {
clearTimeout(timeout);
console.log('fetchWithTimeout: timed out connecting to url: ' + url);
reject();
});
});
}
function paramsToString(params) {
var values = [];
for (var key in params) {
var value = params[key];
if (value !== null && value !== undefined && value !== '') {
values.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
}
}
return values.join('&');
}
function ajax(request) {
if (!request) {
throw new Error("Request cannot be null");
}
request.headers = request.headers || {};
console.log('requesting url: ' + request.url);
return getFetchPromise(request).then(function (response) {
console.log('response status: ' + response.status + ', url: ' + request.url);
if (response.status < 400) {
if (request.dataType == 'json' || request.headers.accept == 'application/json') {
return response.json();
} else {
return response;
}
} else {
return Promise.reject(response);
}
}, function (err) {
console.log('request failed to url: ' + request.url);
throw err;
});
}
return {
getFetchPromise: getFetchPromise,
ajax: ajax
};
});

View file

@ -10,6 +10,8 @@
// Some 1080- videos are reported as 1912?
if (maxAllowedWidth >= 1900) {
options.push({ name: '1080p - 50Mbps', maxHeight: 1080, bitrate: 40000000 });
options.push({ name: '1080p - 45Mbps', maxHeight: 1080, bitrate: 40000000 });
options.push({ name: '1080p - 40Mbps', maxHeight: 1080, bitrate: 40000000 });
options.push({ name: '1080p - 35Mbps', maxHeight: 1080, bitrate: 35000000 });
options.push({ name: '1080p - 30Mbps', maxHeight: 1080, bitrate: 30000000 });