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

108 lines
2.7 KiB
JavaScript
Raw Normal View History

2015-05-26 08:31:50 -07:00
(function () {
function onSuccess() {
console.log('Immersive mode succeeded');
}
function onError() {
console.log('Immersive mode failed');
}
//// 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') {
AndroidFullScreen.showSystemUI(onSuccess, onError);
}
}
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 () {
console.log('binding fullscreen to MediaController');
$(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
})();