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

56 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-04-19 01:56:05 -04:00
import ServerConnections from '../../components/ServerConnections';
2023-03-08 11:03:48 -05:00
import { PluginType } from '../../types/plugin.ts';
import * as userSettings from '../../scripts/settings/userSettings';
class BackdropScreensaver {
constructor() {
2020-05-05 23:51:00 +02:00
this.name = 'Backdrop ScreenSaver';
2023-03-08 11:03:48 -05:00
this.type = PluginType.Screensaver;
2020-05-05 23:51:00 +02:00
this.id = 'backdropscreensaver';
this.supportsAnonymous = false;
}
2023-04-19 01:56:05 -04:00
show() {
const query = {
ImageTypes: 'Backdrop',
EnableImageTypes: 'Backdrop',
IncludeItemTypes: 'Movie,Series,MusicArtist',
SortBy: 'Random',
Recursive: true,
Fields: 'Taglines',
ImageTypeLimit: 1,
StartIndex: 0,
Limit: 200
};
2019-11-23 23:00:44 +03:00
2023-04-19 01:56:05 -04:00
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
}
2023-04-19 01:56:05 -04:00
});
2019-11-23 23:00:44 +03:00
2023-04-19 01:56:05 -04:00
newSlideShow.show();
this.currentSlideshow = newSlideShow;
}).catch(console.error);
2019-11-23 23:00:44 +03:00
}
2023-04-19 01:56:05 -04:00
});
}
hide() {
if (this.currentSlideshow) {
this.currentSlideshow.hide();
this.currentSlideshow = null;
}
2023-04-19 01:56:05 -04:00
return Promise.resolve();
}
2023-04-19 01:56:05 -04:00
}
export default BackdropScreensaver;