soco.plugins.plex module

This plugin supports playback from a linked Plex music service. See:

  • Plex music service must be linked in the Sonos app
  • Use of ‘plexapi’ library (
  • Plex server URI used in ‘plexapi’ must be reachable from Sonos speakers

Example usage:

>>> from plexapi.server import PlexServer
>>> from soco import SoCo
>>> from soco.plugins.plex import PlexPlugin
>>> s = SoCo("<SPEAKER_IP>")
>>> plugin = PlexPlugin(s)
>>> plex_uri = ""
>>> plex_token = "<YOUR_PLEX_TOKEN>"
>>> plex = PlexServer(plex_uri, token=plex_token)
>>> music = plex.library.section("Music")
>>> artist = music.get("Stevie Wonder")
>>> album = artist.album("Innervisions")
>>> track = album.tracks()[4]
>>> playlist = plex.playlist("My Playlist")
>>> plugin.play_now(track)    # Play a single track
>>> plugin.play_now(album)    # Play a complete album
>>> plugin.play_now(artist)   # Play all music from an artist
>>> plugin.play_now(playlist) # Play an existing playlist
class soco.plugins.plex.PlexPlugin(soco)[source]

A SoCo plugin for playing Plex media using the plexapi library.

Initialize the plugin.


Return the name of the plugin.


Return the service name of the Plex music service.


Cache and return the service info of the Plex music service.


Return the service ID of the Plex music service.


Return the service type of the Plex music service.


Insert the media next in the queue and immediately begin playback.

add_to_queue(plex_media, add_next=False)[source]

Add the provided media to the speaker’s playback queue.

  • plex_media (plexapi) – The plexapi object representing the Plex media to be enqueued. Can be one of,, or plexapi.playlist.Playlist.
  • add_next (bool) – True if media should be enqueued after the currently selected track, False to add to the end of the queue.

The index of the new item in the queue.

Return type: