Skip to content

Imaster#236

Open
simojenki wants to merge 6 commits into
simojenki:masterfrom
ianwebster7713:imaster
Open

Imaster#236
simojenki wants to merge 6 commits into
simojenki:masterfrom
ianwebster7713:imaster

Conversation

@simojenki

Copy link
Copy Markdown
Owner

No description provided.

…ta playlist listing

This change corrects how playlists are represented and served via SMAPI so Sonos treats them as actual playlists (not generic containers), and ensures playlist lists are returned from the appropriate endpoint.

What changed

Playlist metadata itemType changed from "container" → "playlist" for:

Individual playlist containers (playlist:${id})

The “Playlists” root node

Removed the “copy/reshape” PlaylistLike hack (and the placeholder entries: []) and now passes the real Playlist object into the playlist metadata builder.

Stopped serving “playlists” via getExtendedMetadata (removed the case "playlists" block there), leaving playlists to be surfaced via the normal metadata browsing path.

Tests updated to assert the new correct SMAPI shape:

"playlists" root is "playlist"

playlist containers are "playlist"

removed canEnumerate expectations for the playlists node/containers

Why

Sonos behaviour differs depending on itemType. Marking playlists as "container" causes them to be treated as generic folders rather than playlist entities, which breaks/impairs playlist semantics (including how entries are browsed/handled).

The prior PlaylistLike rehydration (and fake entries) was an implementation smell that masked the real object shape and made the behaviour inconsistent across SMAPI endpoints.

Moving playlist listing out of getExtendedMetadata reduces ambiguity: extended metadata is for details of an item, not for browsing a collection.
…s as SMAPI itemType=playlist and remove extended-metadata playlist listing
What’s happening (and why the submenu is missing):

In SMAPI getMetadata, the playlist items themselves must come back with itemType: "playlist" (and canPlay: true) for Sonos to expose Play Now / Play Next / Add to End of Queue / Replace Queue.

In the currently-working-build version, the playlist entries were being returned as itemType: "container" — that makes them browsable (so you can see playlist contents) but not treated as a playable playlist object, so Sonos doesn’t show the playback actions.

What I changed:

playlist() helper now returns:

itemType: "playlist" (instead of "container")

keeps canPlay: true and canEnumerate: true

Updated the Jest expectations in smapi.test.ts to match (itemType: "playlist" for playlist entries).

The root “Playlists” node (id: "playlists") remains itemType: "container" (that part was already correct for browsing).
hardens /art/,

avoids invalid headers,

and adds the "[object Object]" guard.
default:
  // Sonos may call getExtendedMetadata on top-level containers
  // (artists, albums, playlists, etc).
  // Returning an empty-but-valid result prevents browse/search errors.
  return getMetadataResult({
    mediaCollection: [],
    index: 0,
    total: 0,
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants