Skip to content

Improvement: Update playMedia to use newer Plex API, reducing requests to initiate playback #1624

Description

@anthonyrom

What is your feature request?

Context: Elan's comment on Plex forums, related issue in homeassistant/core#173564

Suggestion to improve performance by updating the API calls used by playMedia. If my understanding is correct, this would be accomplished by removing the existing playback/playMedia API call and relying on queue creation with paused=0 to create and play the queue in a single API call. If so, it seems like this could be done in a transparently backwards compatible way without changing the signature of playMedia in this library. Elan's comment states that this way to do it has been "supported for years" but it is unclear whether there are some clients which do not support this; in that case, maybe it would be best to fallback to the existing behavior in the event of a failure.

It appears that making this update would add support for Caldera as well as improve performance for existing Plex endpoints.

Are there any workarounds?

No response

Code Snippets

Additional Context

No response

Activity

  1. JonnyWong16 commented on Jul 7, 2026

    @JonnyWong16
    Collaborator

    Could you provide a code snippet that can reproduce the issue?

    I tried this and it seems to be working?

    1. I installed Plexamp and Caldera on my Windows PC.
    2. I make sure there is no session playing inside Plexamp.
    3. Inside Plexamp, I click on the cast icon and select Caldera as the output.
    4. I ran the following script.
    from plexapi.server import PlexServer
    
    plex = PlexServer(token="XXXXXXXXXX")
    plexamp = next(client for client in plex.clients() if client.product == "Plexamp")
    playlist = plex.playlist("My Music")
    plexamp.playMedia(playlist)
    1. Music starts playing from Caldera via the Plexamp controller.
  2. JonnyWong16 commented on Jul 7, 2026

    @JonnyWong16
    Collaborator

    Never mind, I figured it out. Caldera doesn't show up in my list of clients, but I was able to reproduce it by manually connecting to it.

    I think I have an idea for the fix. I won't change the existing client.playMedia method, but instead add a new client.createPlayQueue method that will automatically create the playqueue and start playback in a single command per Elan's comment.

    from plexapi.server import PlexServer
    
    plex = PlexServer(token="XXXXXXXXXX")
    caldera = plex.client("caldera-23e8094c-146e-4996-bece-79dbd908efea")
    playlist = plex.playlist("My Music")
    caldera.createPlayQueue(server, playlist)
  3. anthonyrom commented on Jul 10, 2026

    @anthonyrom
    Author

    Missed your earlier comments but got the notification from this being closed- nice! Thanks for doing that @JonnyWong16 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions