1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/plugins/backdropScreensaver/plugin.js
2023-09-20 07:57:16 +02:00

55 lines
1.8 KiB
JavaScript

import ServerConnections from '../../components/ServerConnections';
import { PluginType } from '../../types/plugin.ts';
import * as userSettings from '../../scripts/settings/userSettings';
class BackdropScreensaver {
constructor() {
this.name = 'BackdropScreensaver';
this.type = PluginType.Screensaver;
this.id = 'backdropscreensaver';
this.supportsAnonymous = false;
}
show() {
const query = {
ImageTypes: 'Backdrop',
EnableImageTypes: 'Backdrop',
IncludeItemTypes: 'Movie,Series,MusicArtist',
SortBy: 'Random',
Recursive: true,
Fields: 'Taglines',
ImageTypeLimit: 1,
StartIndex: 0,
Limit: 200
};
const apiClient = ServerConnections.currentApiClient();
apiClient.getItems(apiClient.getCurrentUserId(), query).then((result) => {
if (result.Items.length) {
import('../../components/slideshow/slideshow').then(({ default: Slideshow }) => {
const newSlideShow = new Slideshow({
showTitle: true,
cover: true,
items: result.Items,
autoplay: {
delay: userSettings.backdropScreensaverInterval() * 1000
}
});
newSlideShow.show();
this.currentSlideshow = newSlideShow;
}).catch(console.error);
}
});
}
hide() {
if (this.currentSlideshow) {
this.currentSlideshow.hide();
this.currentSlideshow = null;
}
return Promise.resolve();
}
}
export default BackdropScreensaver;