Jump to content

Wrong order of metadata in browser media notifications on Windows


Qowy

Recommended Posts

Hi,

i tested this with Firefox Chrome and Edge.

Instead of displaying the Title large and then some additional Information in smallprint emby prints the Band etc. in large.

First I thought that maybe this is a chromium/windows bug, but Spotify web does it correctly.

 

As far as I can see emby uses this JS:

, navigator.mediaSession.metadata = new MediaMetadata({
title: title,
artist: artist,
album: album,
artwork: function(item) {
    var list = [];
    return pushImageUrl(item, 96, list), pushImageUrl(item, 128, list), pushImageUrl(item, 192, list), pushImageUrl(item, 256, list), pushImageUrl(item, 384, list), pushImageUrl(item, 512, list), list
}(item),
albumArtist: albumArtist,
currentTime: currentTime,
duration: duration,
paused: isPaused,
itemId: itemId,
mediaType: item.MediaType
}))

While Spotify uses this:

window.navigator.mediaSession.metadata = new window.MediaMetadata({
    title: e.name,
    artist: Array.isArray(e.artists) ? e.artists.map((e => e.name)).join(", ") : "",
    album: e.album.name,
    artwork: e.album.images.filter((e => e.url)).map((e => ({
        src: e.url,
        sizes: "".concat(e.width, "x").concat(e.height)
    })))
})

So the title variable is filled with the wrong information?

Screenshot 2021-02-04 104803.jpg

Link to comment
Share on other sites

I think I found the error:

function updatePlayerState(player, state) {
    var isVideo, playState, parts, temp, artist, title, albumArtist, album, itemId, duration, currentTime, isPaused,
        item = state.NowPlayingItem;
    item && ((isVideo = "Video" === item.MediaType) || "Audio" === item.MediaType) ? (playState = state.PlayState || {},
        artist = 1 === (parts = nowPlayingHelper.getNowPlayingNames(item)).length ? "" : parts[0].text, title =
        parts[parts.length - 1].text, isVideo && 1 < parts.length && (temp = artist, artist = title, title = temp),
        item.AlbumArtists && item.AlbumArtists[0] && (albumArtist = item.AlbumArtists[0].Name), album = item
        .Album || "", itemId = item.Id, duration = parseInt(item.RunTimeTicks ? item.RunTimeTicks / 1e4 : 0),
        currentTime = parseInt(playState.PositionTicks ? playState.PositionTicks / 1e4 : 0), isPaused = playState
        .IsPaused || !1, navigator.mediaSession.metadata = new MediaMetadata({
...

Artist is Parts[0] Title is parts[parts.length -1] but nowPlayingHelper.getNowPlayingNames returns:

topItem = {
                Id: nowPlayingItem.AlbumId,
                Name: nowPlayingItem.Album,
                Type: "MusicAlbum",
                IsFolder: !0
...

bottomItem = {
                Id: nowPlayingItem.ArtistItems[0].Id,
                Name: nowPlayingItem.ArtistItems[0].Name,
                Type: "MusicArtist",
                IsFolder: !0

...

return list.push({
                text: topText,
                item: topItem
            }), bottomText && list.push({
                text: bottomText,
                item: bottomItem
            }), list

Which is the other way around.

 

EDIT:

yes switching [0] with parts[parts.length -1] fixes the issue. However someone probably needs to check if it still works for videos and other types of media.

TV Shows now display the episode in large and Name of the show in small, that seems right, but no idea how it is intended

Edited by Qowy
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...