From b4345010a40f614b59b08458d3ca552b8de04da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pauli=20J=C3=A4rvinen?= Date: Sat, 6 Jan 2024 22:10:23 +0200 Subject: [PATCH] Fix two issues caused by earlier embedded player NC28-compatibility fixes - It turned out that appending the OC.requestToken to the play URL was not totally unnecessary after all: without it, using the Aurora.js fallback player (to play e.g. AIFF files) didn't work although all the natively supported files played fine. - The logic to show "Import playlist" or "Import radio" didn't work correctly because it was based on the assumption that only external streams may have the property `url` set --- js/embedded/main.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/js/embedded/main.js b/js/embedded/main.js index 14d500d75..07fdf5cd8 100644 --- a/js/embedded/main.js +++ b/js/embedded/main.js @@ -53,6 +53,18 @@ function initEmbeddedPlayer() { register(); + function urlForFile(file) { + let url = file.url ?? mFileList.getDownloadUrl(file.name, file.path); + + // Append request token unless this is a public share. This is actually unnecessary for most files + // but needed when the file in question is played using our Aurora.js fallback player. + if (!mShareToken) { + let delimiter = _.includes(url, '?') ? '&' : '?'; + url += delimiter + 'requesttoken=' + encodeURIComponent(OC.requestToken); + } + return url; + } + function onClose() { mCurrentFile = null; mPlayingListFile = false; @@ -89,7 +101,7 @@ function initEmbeddedPlayer() { // disable/enable the "Import list to Music" item let inLibraryFilesCount = _(mPlaylist.files()).filter('in_library').size(); - let extStreamsCount = _(mPlaylist.files()).filter('url').size(); + let extStreamsCount = _(mPlaylist.files()).filter('external').size(); let outLibraryFilesCount = mPlaylist.length() - inLibraryFilesCount; let $importListItem = $menu.find('#playlist-menu-import'); @@ -171,7 +183,7 @@ function initEmbeddedPlayer() { mPlayer.playExtUrl(file.url, file.caption, mShareToken); } else { mPlayer.playFile( - file.url ?? mFileList.getDownloadUrl(file.name, file.path), + urlForFile(file), file.mimetype, file.id, file.name,