jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/playback/playbackvalidation.js

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-01-11 21:27:01 -07:00
define(['playbackManager'], function (playbackManager) {
"use strict";
return function () {
var self = this;
self.name = 'Playback validation';
self.type = 'preplayintercept';
self.id = 'playbackvalidation';
self.order = -1;
self.intercept = function (options) {
2017-01-14 01:03:46 -07:00
// Don't care about video backdrops, or theme music or any kind of non-fullscreen playback
if (!options.fullscreen) {
2017-01-11 21:27:01 -07:00
return Promise.resolve();
}
return validatePlayback(options);
};
function validatePlayback(options) {
return new Promise(function (resolve, reject) {
require(["registrationServices"], function (registrationServices) {
2017-01-12 14:11:29 -07:00
registrationServices.validateFeature('playback', options).then(function (result) {
if (result && result.enableTimeLimit) {
startAutoStopTimer();
}
2017-01-11 21:27:01 -07:00
resolve();
});
});
});
}
var autoStopTimeout;
var lockedTimeLimitMs = 63000;
function startAutoStopTimer() {
stopAutoStopTimer();
autoStopTimeout = setTimeout(onAutoStopTimeout, lockedTimeLimitMs);
}
function onAutoStopTimeout() {
stopAutoStopTimer();
playbackManager.stop();
}
function stopAutoStopTimer() {
var timeout = autoStopTimeout;
if (timeout) {
clearTimeout(timeout);
autoStopTimeout = null;
}
}
};
});