Skip to content

Commit

Permalink
Fix two issues caused by earlier embedded player NC28-compatibility f…
Browse files Browse the repository at this point in the history
…ixes

- 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
  • Loading branch information
paulijar committed Jan 6, 2024
1 parent 4053fd7 commit b434501
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions js/embedded/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b434501

Please sign in to comment.