jellyfin-web/dashboard-ui/cordova/android/immersive.js

111 lines
2.8 KiB
JavaScript
Raw Normal View History

2015-05-26 08:31:50 -07:00
(function () {
function onSuccess() {
2015-06-26 20:27:38 -07:00
Logger.log('Immersive mode succeeded');
2015-05-26 08:31:50 -07:00
}
function onError() {
2015-06-26 20:27:38 -07:00
Logger.log('Immersive mode failed');
2015-05-26 08:31:50 -07:00
}
//// Is this plugin supported?
//AndroidFullScreen.isSupported();
//// Is immersive mode supported?
2015-05-27 22:51:48 -07:00
//AndroidFullScreen.isImmersiveModeSupported(onSuccess, onError);
2015-05-26 08:31:50 -07:00
//// The width of the screen in immersive mode
2015-05-27 22:51:48 -07:00
//AndroidFullScreen.immersiveWidth(trace, onError);
2015-05-26 08:31:50 -07:00
//// The height of the screen in immersive mode
2015-05-27 22:51:48 -07:00
//AndroidFullScreen.immersiveHeight(trace, onError);
2015-05-26 08:31:50 -07:00
//// Hide system UI until user interacts
2015-05-27 22:51:48 -07:00
//AndroidFullScreen.leanMode(onSuccess, onError);
2015-05-26 08:31:50 -07:00
//// Show system UI
2015-05-27 22:51:48 -07:00
//AndroidFullScreen.showSystemUI(onSuccess, onError);
2015-05-26 08:31:50 -07:00
//// Extend your app underneath the system UI (Android 4.4+ only)
2015-05-27 22:51:48 -07:00
//AndroidFullScreen.showUnderSystemUI(onSuccess, onError);
2015-05-26 08:31:50 -07:00
//// Hide system UI and keep it hidden (Android 4.4+ only)
2015-05-27 22:51:48 -07:00
//AndroidFullScreen.immersiveMode(onSuccess, onError);
var currentPlayer;
function onPlaybackStart(e, state) {
var player = this;
if (player.isLocalPlayer && state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') {
AndroidFullScreen.immersiveMode(onSuccess, onError);
}
}
function onPlaybackStopped(e, state) {
var player = this;
if (player.isLocalPlayer && state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') {
2015-06-04 13:27:46 -07:00
if (!AppSettings.enableFullScreen()) {
AndroidFullScreen.showSystemUI(onSuccess, onError);
}
2015-05-27 22:51:48 -07:00
}
}
function bindToPlayer(player) {
releaseCurrentPlayer();
currentPlayer = player;
if (!player.isLocalPlayer) {
return;
}
$(player).on('playbackstart.fullscreen', onPlaybackStart)
.on('playbackstop.fullscreen', onPlaybackStopped);
}
function releaseCurrentPlayer() {
if (currentPlayer) {
$(currentPlayer).off('.fullscreen');
}
}
function updateFromSetting(leaveFullScreen) {
if (AppSettings.enableFullScreen()) {
AndroidFullScreen.immersiveMode(onSuccess, onError);
}
else if (leaveFullScreen) {
AndroidFullScreen.showSystemUI(onSuccess, onError);
}
}
Dashboard.ready(function () {
2015-06-26 20:27:38 -07:00
Logger.log('binding fullscreen to MediaController');
2015-05-27 22:51:48 -07:00
$(MediaController).on('playerchange', function () {
bindToPlayer(MediaController.getCurrentPlayer());
});
bindToPlayer(MediaController.getCurrentPlayer());
updateFromSetting(false);
$(AppSettings).on('settingupdated', function (e, key) {
if (key == 'enableFullScreen') {
updateFromSetting(true);
}
});
});
2015-05-26 08:31:50 -07:00
})();