Skip to content

Commit

Permalink
playing: Initial podcasts support
Browse files Browse the repository at this point in the history
  • Loading branch information
busybox11 committed Aug 27, 2024
1 parent cc2000a commit e30a3c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions assets/js/playing.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ document.addEventListener('alpine:init', x => {
await this.refreshToken();
}

const response = await spotifyApi.getMyCurrentPlaybackState();
const response = await spotifyApi.getMyCurrentPlaybackState({
additional_types: "episode"
});
if (response) {
this.handleChange(response);
}
Expand All @@ -90,15 +92,17 @@ document.addEventListener('alpine:init', x => {
this.lastPlaybackObj = this.playbackObj;
this.playbackObj = obj;

const artists = this.playbackObj.item?.artists || [{ name: this.playbackObj.item?.show?.publisher }]

if (this.playbackObj.item?.name) {
document.title = `${this.playbackObj.item?.name} - ${this.playbackObj.item?.artists[0].name} - NowPlaying`;
document.title = `${this.playbackObj.item?.name} - ${artists[0].name} - NowPlaying`;
}

// Fetch album art
const imgsArr = this.playbackObj.item?.album?.images;
const imgsArr = this.playbackObj.item?.album?.images || this.playbackObj.item?.images;
const targetImg = (useSmallAlbumCover) ? imgsArr[imgsArr.length - 2]?.url : imgsArr[0]?.url;

const lastImgsArr = this.lastPlaybackObj.item?.album?.images;
const lastImgsArr = this.lastPlaybackObj.item?.album?.images || this.lastPlaybackObj.item?.images;
if (lastImgsArr === undefined) {
this.targetImg = targetImg;
return;
Expand Down
2 changes: 1 addition & 1 deletion miniplayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class="text-3xl font-bold text-pretty" :class="{
}"></h1>

<h2
x-text="$store.player.playbackObj.item?.artists?.map(artist => artist.name).join(', ') ?? translations.defaultArtistSong"
x-text="$store.player.playbackObj.item?.artists?.map(artist => artist.name).join(', ') ?? $store.player.playbackObj.item?.show?.publisher ?? translations.defaultArtistSong"
id="song-artist" class="text-xl font-semibold line-clamp-1 text-pretty" :class="{ 'opacity-80': !showAlbum }">
</h2>

Expand Down
2 changes: 1 addition & 1 deletion playing.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class="absolute bottom-6 left-6 z-30 flex flex-row bg-black/20 border-2 border-w
<h1 x-text="$store.player.playbackObj.item?.name ?? translations.defaultTitleSong" id="song-title"
class="text-4xl lg:text-7xl font-bold text-pretty">
</h1>
<h2 x-text="$store.player.playbackObj.item?.artists?.map(artist => artist.name).join(', ') ?? translations.defaultArtistSong"
<h2 x-text="$store.player.playbackObj.item?.artists?.map(artist => artist.name).join(', ') ?? $store.player.playbackObj.item?.show?.publisher ?? translations.defaultArtistSong"
id="song-artist" class="text-2xl lg:text-5xl font-bold text-pretty">
</h2>
<h3 x-text="$store.player.playbackObj?.item?.album?.name" id="song-album"
Expand Down

0 comments on commit e30a3c1

Please sign in to comment.