Skip to content

Support Plex resuming and playback offset#61468

Merged
bdraco merged 1 commit intohome-assistant:devfrom
jjlawren:plex_resume_and_offset
Dec 20, 2021
Merged

Support Plex resuming and playback offset#61468
bdraco merged 1 commit intohome-assistant:devfrom
jjlawren:plex_resume_and_offset

Conversation

@jjlawren
Copy link
Copy Markdown
Contributor

Proposed change

Support two new parameters in the media_content_id payload for Plex media_player.play_media service calls:

  • resume: Resume playback from the last known position
  • offset: Begin playback at X seconds from the beginning

If both are included, offset will take precedence.

Examples:

service: media_player.play_media
target:
  entity_id: media_player.plex_player
data:
  media_content_type: movie
  media_content_id: '{ "library_name": "Movies", "movie.title": "Elf", "resume": true }'
service: media_player.play_media
target:
  entity_id: media_player.plex_player
data:
  media_content_type: tvshow
  media_content_id: >-
    {
      "library_name": "TV Shows",
      "show.title": "Futurama",
      "season.index": 5,
      "episode.index": 2,
      "offset": 300            # Begins playback 5 minutes into the episode
    }

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Dec 19, 2021

This looks fine. The service taking a json string seems a bit odd though... I don't know the history here, but was there a reason something like this can't work?

service: media_player.play_media
target:
  entity_id: media_player.plex_player
data:
  media_content_type: tvshow
  media_content_id:
      library_name: "TV Shows"
      show.title: Futurama
      season.index: 5
      episode.index: 2
      offset: 300           

@jjlawren
Copy link
Copy Markdown
Contributor Author

Legacy conventions. Could possibly be refactored to accept both ways but it is probably better to come up with a new convention to handle this more cleanly in all media players.

@bdraco bdraco merged commit d64e7b1 into home-assistant:dev Dec 20, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2021
@jjlawren jjlawren deleted the plex_resume_and_offset branch December 25, 2021 17:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plex play_media doesn't support current_time parameter

3 participants