mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-15 18:08:17 -07:00
Migration of themeMediaPlayer to ES6 module
This commit is contained in:
parent
42ac558a17
commit
e813f64cd2
@ -167,6 +167,7 @@
|
||||
"src/components/syncPlay/playbackPermissionManager.js",
|
||||
"src/components/syncPlay/syncPlayManager.js",
|
||||
"src/components/syncPlay/timeSyncManager.js",
|
||||
"src/components/themeMediaPlayer.js",
|
||||
"src/components/toast/toast.js",
|
||||
"src/components/upnextdialog/upnextdialog.js",
|
||||
"src/components/viewContainer.js",
|
||||
|
@ -1,103 +1,102 @@
|
||||
define(['playbackManager', 'userSettings', 'connectionManager'], function (playbackManager, userSettings, connectionManager) {
|
||||
'use strict';
|
||||
import playbackManager from 'playbackManager';
|
||||
import userSettings from 'userSettings';
|
||||
import connectionManager from 'connectionManager';
|
||||
|
||||
playbackManager = playbackManager.default || playbackManager;
|
||||
let currentOwnerId;
|
||||
let currentThemeIds = [];
|
||||
|
||||
var currentOwnerId;
|
||||
var currentThemeIds = [];
|
||||
function playThemeMedia(items, ownerId) {
|
||||
const currentThemeItems = items.filter(function (i) {
|
||||
return enabled(i.MediaType);
|
||||
});
|
||||
|
||||
function playThemeMedia(items, ownerId) {
|
||||
var currentThemeItems = items.filter(function (i) {
|
||||
return enabled(i.MediaType);
|
||||
if (currentThemeItems.length) {
|
||||
// Stop if a theme song from another ownerId
|
||||
// Leave it alone if anything else (e.g user playing a movie)
|
||||
if (!currentOwnerId && playbackManager.isPlaying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentThemeIds = currentThemeItems.map(function (i) {
|
||||
return i.Id;
|
||||
});
|
||||
|
||||
if (currentThemeItems.length) {
|
||||
// Stop if a theme song from another ownerId
|
||||
// Leave it alone if anything else (e.g user playing a movie)
|
||||
if (!currentOwnerId && playbackManager.isPlaying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentThemeIds = currentThemeItems.map(function (i) {
|
||||
return i.Id;
|
||||
});
|
||||
|
||||
playbackManager.play({
|
||||
items: currentThemeItems,
|
||||
fullscreen: false,
|
||||
enableRemotePlayers: false
|
||||
}).then(function () {
|
||||
currentOwnerId = ownerId;
|
||||
});
|
||||
} else {
|
||||
stopIfPlaying();
|
||||
}
|
||||
}
|
||||
|
||||
function stopIfPlaying() {
|
||||
if (currentOwnerId) {
|
||||
playbackManager.stop();
|
||||
}
|
||||
|
||||
currentOwnerId = null;
|
||||
}
|
||||
|
||||
function enabled(mediaType) {
|
||||
if (mediaType === 'Video') {
|
||||
return userSettings.enableThemeVideos();
|
||||
}
|
||||
|
||||
return userSettings.enableThemeSongs();
|
||||
}
|
||||
|
||||
var excludeTypes = ['CollectionFolder', 'UserView', 'Program', 'SeriesTimer', 'Person', 'TvChannel', 'Channel'];
|
||||
|
||||
function loadThemeMedia(item) {
|
||||
if (item.CollectionType) {
|
||||
stopIfPlaying();
|
||||
return;
|
||||
}
|
||||
|
||||
if (excludeTypes.indexOf(item.Type) !== -1) {
|
||||
stopIfPlaying();
|
||||
return;
|
||||
}
|
||||
|
||||
var apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
apiClient.getThemeMedia(apiClient.getCurrentUserId(), item.Id, true).then(function (themeMediaResult) {
|
||||
var ownerId = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.OwnerId : themeMediaResult.ThemeSongsResult.OwnerId;
|
||||
|
||||
if (ownerId !== currentOwnerId) {
|
||||
var items = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.Items : themeMediaResult.ThemeSongsResult.Items;
|
||||
|
||||
playThemeMedia(items, ownerId);
|
||||
}
|
||||
playbackManager.play({
|
||||
items: currentThemeItems,
|
||||
fullscreen: false,
|
||||
enableRemotePlayers: false
|
||||
}).then(function () {
|
||||
currentOwnerId = ownerId;
|
||||
});
|
||||
} else {
|
||||
stopIfPlaying();
|
||||
}
|
||||
}
|
||||
|
||||
function stopIfPlaying() {
|
||||
if (currentOwnerId) {
|
||||
playbackManager.stop();
|
||||
}
|
||||
|
||||
document.addEventListener('viewshow', function (e) {
|
||||
var state = e.detail.state || {};
|
||||
var item = state.item;
|
||||
currentOwnerId = null;
|
||||
}
|
||||
|
||||
if (item && item.ServerId) {
|
||||
loadThemeMedia(item);
|
||||
return;
|
||||
}
|
||||
function enabled(mediaType) {
|
||||
if (mediaType === 'Video') {
|
||||
return userSettings.enableThemeVideos();
|
||||
}
|
||||
|
||||
var viewOptions = e.detail.options || {};
|
||||
return userSettings.enableThemeSongs();
|
||||
}
|
||||
|
||||
if (viewOptions.supportsThemeMedia) {
|
||||
// Do nothing here, allow it to keep playing
|
||||
} else {
|
||||
playThemeMedia([], null);
|
||||
}
|
||||
}, true);
|
||||
const excludeTypes = ['CollectionFolder', 'UserView', 'Program', 'SeriesTimer', 'Person', 'TvChannel', 'Channel'];
|
||||
|
||||
Events.on(playbackManager, 'playbackstart', function (e, player) {
|
||||
var item = playbackManager.currentItem(player);
|
||||
// User played something manually
|
||||
if (currentThemeIds.indexOf(item.Id) == -1) {
|
||||
currentOwnerId = null;
|
||||
function loadThemeMedia(item) {
|
||||
if (item.CollectionType) {
|
||||
stopIfPlaying();
|
||||
return;
|
||||
}
|
||||
|
||||
if (excludeTypes.indexOf(item.Type) !== -1) {
|
||||
stopIfPlaying();
|
||||
return;
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
apiClient.getThemeMedia(apiClient.getCurrentUserId(), item.Id, true).then(function (themeMediaResult) {
|
||||
const ownerId = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.OwnerId : themeMediaResult.ThemeSongsResult.OwnerId;
|
||||
|
||||
if (ownerId !== currentOwnerId) {
|
||||
const items = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.Items : themeMediaResult.ThemeSongsResult.Items;
|
||||
|
||||
playThemeMedia(items, ownerId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('viewshow', function (e) {
|
||||
const state = e.detail.state || {};
|
||||
const item = state.item;
|
||||
|
||||
if (item && item.ServerId) {
|
||||
loadThemeMedia(item);
|
||||
return;
|
||||
}
|
||||
|
||||
const viewOptions = e.detail.options || {};
|
||||
|
||||
if (viewOptions.supportsThemeMedia) {
|
||||
// Do nothing here, allow it to keep playing
|
||||
} else {
|
||||
playThemeMedia([], null);
|
||||
}
|
||||
}, true);
|
||||
|
||||
Events.on(playbackManager, 'playbackstart', function (e, player) {
|
||||
const item = playbackManager.currentItem(player);
|
||||
// User played something manually
|
||||
if (currentThemeIds.indexOf(item.Id) == -1) {
|
||||
currentOwnerId = null;
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user