1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

use unified theme media player

This commit is contained in:
Luke Pulverenti 2016-08-21 02:59:36 -04:00
parent 50f9d7d4fe
commit d8c4154947
12 changed files with 93 additions and 144 deletions

View file

@ -1531,16 +1531,7 @@
renderThemeSongs(page, themeSongs);
renderThemeVideos(page, themeVideos);
page.dispatchEvent(new CustomEvent("thememediadownload", {
detail: {
themeMediaResult: result
},
bubbles: true
}));
});
}
function renderThemeSongs(page, items) {

View file

@ -1,4 +1,4 @@
define(['jQuery'], function ($) {
define(['jQuery', 'fnchecked'], function ($) {
function loadPage(page, config, languages) {
@ -25,7 +25,7 @@
var culture = languages[i];
html += '<paper-checkbox class="chkLang" data-lang="' + culture.ThreeLetterISOLanguageName.toLowerCase() + '">' + culture.DisplayName + '</paper-checkbox>';
html += '<label><input type="checkbox" is="emby-checkbox" class="chkLang" data-lang="' + culture.ThreeLetterISOLanguageName.toLowerCase() + '" /><span>' + culture.DisplayName + '</span></label>';
}
$('.downloadLanguages', page).html(html);

View file

@ -1,4 +1,4 @@
define(['loading', 'apphost', 'globalize', 'syncJobList', 'events', 'localsync', 'emby-button', 'paper-icon-button-light'], function (loading, appHost, globalize, syncJobList, events, localSync) {
define(['apphost', 'globalize', 'syncJobList', 'events', 'localsync', 'emby-button', 'paper-icon-button-light'], function (appHost, globalize, syncJobList, events, localSync) {
function initSupporterInfo(view, params) {
@ -40,13 +40,6 @@
var status = localSync.getSyncStatus();
page.querySelector('.labelSyncStatus').innerHTML = Globalize.translate('LabelLocalSyncStatusValue', status);
if (status == 'Active') {
loading.show();
} else {
loading.hide();
}
if (status == "Active") {
page.querySelector('.btnSyncNow').classList.add('hide');
}
@ -103,8 +96,6 @@
view.addEventListener('viewbeforehide', function () {
loading.hide();
if (interval) {
clearInterval(interval);
interval = null;

View file

@ -179,7 +179,7 @@ var Dashboard = {
}
if (url.indexOf('/') != 0) {
if (url.indexOf('http') != 0 && url.indexOf('file:') != 0) {
if (url.indexOf('://') == -1) {
url = '/' + url;
}
}
@ -1528,10 +1528,21 @@ var AppInfo = {};
// mock this for now. not used in this app
define("playbackManager", [], function () {
return {
isPlaying: function () {
return MediaPlayer.currentItem != null;
},
isPlayingVideo: function () {
return false;
return MediaPlayer.currentItem != null;
},
play: function (options) {
if (options.fullscreen === false) {
// theme backdrops - not supported
if (!options.items || options.items[0].MediaType == 'Video') {
return;
}
}
MediaController.play(options);
},
currentPlaylistIndex: function (options) {
@ -1554,6 +1565,9 @@ var AppInfo = {};
},
pause: function () {
return MediaController.pause();
},
stop: function () {
return MediaController.stop();
}
};
});
@ -1645,7 +1659,7 @@ var AppInfo = {};
apiClient.getItem(apiClient.getCurrentUserId(), item).then(showItem);
});
} else {
Dashboard.navigate(LibraryBrowser.getHref(item));
Emby.Page.show('/' + LibraryBrowser.getHref(item), { item: item });
}
}
@ -2726,7 +2740,7 @@ var AppInfo = {};
var postInitDependencies = [];
postInitDependencies.push('scripts/thememediaplayer');
postInitDependencies.push('bower_components/emby-webcomponents/thememediaplayer');
postInitDependencies.push('scripts/remotecontrol');
postInitDependencies.push('css!css/chromecast.css');
postInitDependencies.push('scripts/autobackdrops');

View file

@ -1,76 +0,0 @@
define(['appStorage'], function (appStorage) {
var currentOwnerId;
var currentThemeIds = [];
function playThemeSongs(items, ownerId) {
var player = getPlayer();
if (items.length && player.isDefaultPlayer && player.canAutoPlayAudio()) {
// Stop if a theme song from another ownerId
// Leave it alone if anything else (e.g user playing a movie)
if (!currentOwnerId && player.isPlaying()) {
return;
}
currentThemeIds = items.map(function (i) {
return i.Id;
});
currentOwnerId = ownerId;
player.play({
items: items
});
} else {
currentOwnerId = null;
}
}
function onPlayItem(item) {
// User played something manually
if (currentThemeIds.indexOf(item.Id) == -1) {
currentOwnerId = null;
}
}
function enabled() {
var userId = Dashboard.getCurrentUserId();
var val = appStorage.getItem('enableThemeSongs-' + userId);
var localAutoPlayers = MediaController.getPlayers().filter(function (p) {
return p.isLocalPlayer && p.canAutoPlayAudio();
});
// For bandwidth
return val == '1' || (val != '0' && localAutoPlayers.length);
}
function getPlayer() {
return MediaController.getCurrentPlayer();
}
document.addEventListener('thememediadownload', function (e) {
if (!enabled()) {
return;
}
var themeMediaResult = e.detail.themeMediaResult;
var ownerId = themeMediaResult.ThemeSongsResult.OwnerId;
if (ownerId != currentOwnerId) {
playThemeSongs(themeMediaResult.ThemeSongsResult.Items, ownerId);
}
});
});