Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Enhance NativeShell for JMP.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwalton3 committed Apr 11, 2021
1 parent 0744dbf commit 9b72604
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
8 changes: 5 additions & 3 deletions src/components/apphost.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const supportedFeatures = function () {
*/
function doExit() {
try {
if (window.NativeShell) {
if (window.NativeShell && window.NativeShell.AppHost.exit) {
window.NativeShell.AppHost.exit();
} else if (browser.tizen) {
tizen.application.getCurrentApplication().exit();
Expand Down Expand Up @@ -361,10 +361,12 @@ export const appHost = {
};
},
deviceName: function () {
return window.NativeShell ? window.NativeShell.AppHost.deviceName() : getDeviceName();
return window.NativeShell && window.NativeShell.AppHost.deviceName
? window.NativeShell.AppHost.deviceName() : getDeviceName();
},
deviceId: function () {
return window.NativeShell ? window.NativeShell.AppHost.deviceId() : getDeviceId();
return window.NativeShell && window.NativeShell.AppHost.deviceId
? window.NativeShell.AppHost.deviceId() : getDeviceId();
},
appName: function () {
return window.NativeShell ? window.NativeShell.AppHost.appName() : appName;
Expand Down
7 changes: 6 additions & 1 deletion src/components/pluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import globalize from '../scripts/globalize';
import loading from './loading/loading';
import appSettings from '../scripts/settings/appSettings';
import { playbackManager } from './playback/playbackmanager';
import { appHost } from '../components/apphost';
import { appRouter } from '../components/appRouter';

/* eslint-disable indent */

Expand Down Expand Up @@ -90,7 +92,10 @@ import { playbackManager } from './playback/playbackmanager';
events: Events,
loading,
appSettings,
playbackManager
playbackManager,
globalize,
appHost,
appRouter
});
} else {
console.debug(`Loading plugin (via dynamic import): ${pluginSpec}`);
Expand Down
9 changes: 0 additions & 9 deletions src/scripts/settings/webSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ export function getMultiServer() {
});
}

export function getIgnorePlayPermission() {
return getConfig().then(config => {
return !!config.ignorePlayPermission;
}).catch(error => {
console.log('cannot get web config:', error);
return false;
});
}

export function getServers() {
return getConfig().then(config => {
return config.servers || [];
Expand Down
20 changes: 15 additions & 5 deletions src/scripts/shell.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// TODO: This seems like a good candidate for deprecation
export default {
enableFullscreen: function() {
window.NativeShell?.enableFullscreen();
if (window.NativeShell && window.NativeShell.enableFullscreen) {
window.NativeShell.enableFullscreen();
}
},
disableFullscreen: function() {
window.NativeShell?.disableFullscreen();
if (window.NativeShell && window.NativeShell.disableFullscreen) {
window.NativeShell.disableFullscreen();
}
},
openUrl: function(url, target) {
if (window.NativeShell) {
Expand All @@ -14,17 +18,23 @@ export default {
}
},
updateMediaSession(mediaInfo) {
window.NativeShell?.updateMediaSession(mediaInfo);
if (window.NativeShell && window.NativeShell.updateMediaSession) {
window.NativeShell.updateMediaSession(mediaInfo);
}
},
hideMediaSession() {
window.NativeShell?.hideMediaSession();
if (window.NativeShell && window.NativeShell.hideMediaSession) {
window.NativeShell.hideMediaSession();
}
},
/**
* Notify the NativeShell about volume level changes.
* Useful for e.g. remote playback.
*/
updateVolumeLevel(volume) {
window.NativeShell?.updateVolumeLevel(volume);
if (window.NativeShell && window.NativeShell.updateVolumeLevel) {
window.NativeShell.updateVolumeLevel(volume);
}
},
/**
* Download specified files with NativeShell if possible
Expand Down

0 comments on commit 9b72604

Please sign in to comment.