1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Improve NativeShell integration

- Move NativeShell calls into shell.js where possible to better group them
- Add "updateVolumeLevel" API (not used yet)
This commit is contained in:
Maxr1998 2020-07-28 23:54:27 +02:00
parent bef58052fa
commit 7adc288ca6
No known key found for this signature in database
GPG key ID: 3BA0CD3A11CDF7B8
3 changed files with 35 additions and 15 deletions

View file

@ -1,5 +1,6 @@
import playbackManager from 'playbackManager'; import playbackManager from 'playbackManager';
import nowPlayingHelper from 'nowPlayingHelper'; import nowPlayingHelper from 'nowPlayingHelper';
import shell from 'shell';
import events from 'events'; import events from 'events';
/* eslint-disable indent */ /* eslint-disable indent */
@ -127,8 +128,7 @@ import events from 'events';
}); });
} else { } else {
const itemImageUrl = seriesImageUrl(item, { maxHeight: 3000 }) || imageUrl(item, { maxHeight: 3000 }); const itemImageUrl = seriesImageUrl(item, { maxHeight: 3000 }) || imageUrl(item, { maxHeight: 3000 });
shell.updateMediaSession({
window.NativeShell.updateMediaSession({
action: eventName, action: eventName,
isLocalPlayer: isLocalPlayer, isLocalPlayer: isLocalPlayer,
itemId: itemId, itemId: itemId,
@ -182,7 +182,7 @@ import events from 'events';
/* eslint-disable-next-line compat/compat */ /* eslint-disable-next-line compat/compat */
navigator.mediaSession.metadata = null; navigator.mediaSession.metadata = null;
} else { } else {
window.NativeShell.hideMediaSession(); shell.hideMediaSession();
} }
} }

View file

@ -1,11 +1,8 @@
import multiDownload from 'multi-download'; import multiDownload from 'multi-download';
import shell from 'shell';
export function download(items) { export function download(items) {
if (window.NativeShell) { if (!shell.downloadFiles(items)) {
items.map(function (item) {
window.NativeShell.downloadFile(item);
});
} else {
multiDownload(items.map(function (item) { multiDownload(items.map(function (item) {
return item.url; return item.url;
})); }));

View file

@ -1,5 +1,11 @@
// TODO: This seems like a good candidate for deprecation // TODO: This seems like a good candidate for deprecation
export default { export default {
enableFullscreen: function() {
window.NativeShell?.enableFullscreen();
},
disableFullscreen: function() {
window.NativeShell?.disableFullscreen();
},
openUrl: function(url, target) { openUrl: function(url, target) {
if (window.NativeShell) { if (window.NativeShell) {
window.NativeShell.openUrl(url, target); window.NativeShell.openUrl(url, target);
@ -7,14 +13,31 @@ export default {
window.open(url, target || '_blank'); window.open(url, target || '_blank');
} }
}, },
enableFullscreen: function () { updateMediaSession(mediaInfo) {
if (window.NativeShell) { window.NativeShell?.updateMediaSession(mediaInfo);
window.NativeShell.enableFullscreen();
}
}, },
disableFullscreen: function () { hideMediaSession() {
window.NativeShell?.hideMediaSession();
},
/**
* Notify the NativeShell about volume level changes.
* Useful for e.g. remote playback.
*/
updateVolumeLevel(volume) {
window.NativeShell?.updateVolumeLevel(volume);
},
/**
* Download specified files with NativeShell if possible
*
* @returns true on success
*/
downloadFiles(items) {
if (window.NativeShell) { if (window.NativeShell) {
window.NativeShell.disableFullscreen(); items.map(function(item) {
window.NativeShell.downloadFile(item);
});
return true;
} }
return false;
} }
}; };