jellyfish-web/src/plugins/photoPlayer/plugin.js
2021-09-09 00:45:01 +03:00

40 lines
1.4 KiB
JavaScript

import ServerConnections from '../../components/ServerConnections';
export default class PhotoPlayer {
constructor() {
this.name = 'Photo Player';
this.type = 'mediaplayer';
this.id = 'photoplayer';
this.priority = 1;
}
play(options) {
return new Promise(function (resolve) {
import('../../components/slideshow/slideshow').then(({default: Slideshow}) => {
const index = options.startIndex || 0;
const apiClient = ServerConnections.currentApiClient();
apiClient.getCurrentUser().then(function(result) {
const newSlideShow = new Slideshow({
showTitle: false,
cover: false,
items: options.items,
startIndex: index,
interval: 11000,
interactive: true,
// playbackManager.shuffle has no options. So treat 'shuffle' as a 'play' action
autoplay: options.autoplay || options.shuffle,
user: result
});
newSlideShow.show();
resolve();
});
});
});
}
canPlayMediaType(mediaType) {
return (mediaType || '').toLowerCase() === 'photo';
}
}