Skip to content

Commit

Permalink
domains: review spotify compact and normal player height
Browse files Browse the repository at this point in the history
  • Loading branch information
iparamonau committed Jan 24, 2025
1 parent e443492 commit 8ed7831
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions plugins/domains/spotify.com.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ export default {

getLink: function(iframe, options) {

const COMPACT_PLAYER_HEIGHT = 152;
const NORMAL_PLAYER_HEIGHT = 352;

if (iframe.src) {

var horizontal_player = options.getRequestOptions('players.horizontal', false);
var compact_player = options.getRequestOptions('spotify.compact', options.getRequestOptions('players.horizontal', true));

var player = {
href: iframe.src,
Expand All @@ -50,32 +53,31 @@ export default {
value: include_playlist
};
player.media = {
height: !include_playlist ? 80 : (iframe.height || 400)
height: !include_playlist ? COMPACT_PLAYER_HEIGHT : (iframe.height || NORMAL_PLAYER_HEIGHT)
};

} else if (/episode/.test(iframe.src)) {
var isVideo = !!iframe.width; // 100% width for audio episodes is not set in `iframe`
if (!isVideo) player.rel.push(CONFIG.R.audio);
player.media = isVideo && iframe.height
? {'aspect-ratio' : iframe.width / iframe.height}
: {height: iframe.height || 152}
} else if (/episode/.test(iframe.src) && /* isVideo */ !!iframe.width) { // 100% width for audio episodes is not set in `iframe`
player.media = iframe.height
? {'aspect-ratio' : iframe.width / iframe.height}
: {height: COMPACT_PLAYER_HEIGHT}

// else /track/ or /show/
// else /track/ or /show or audio /episode (the once without 100% width)
} else {
player.rel.push(CONFIG.R.audio);
player.options.horizontal = {
player.options.compact = {
label: CONFIG.L.horizontal,
value: horizontal_player === true
value: compact_player === true
};

player.media = {
height: horizontal_player ? 80: 152
player.media = compact_player ? {
height: COMPACT_PLAYER_HEIGHT,
} : {
height: NORMAL_PLAYER_HEIGHT
};
}

return player;
}

},

getData: function (url, options, cb) {
Expand Down

0 comments on commit 8ed7831

Please sign in to comment.