Skip to content

Commit

Permalink
Correct track chapter play
Browse files Browse the repository at this point in the history
  • Loading branch information
cdnninja committed Jun 17, 2024
1 parent 95955c7 commit c2cb00f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions custom_components/yoto/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ async def async_play_card(
chapter: int = 1,
trackkey: int = 1,
) -> None:
if trackkey is None:
trackkey = 1
if chapter is None:
trackkey = 1
await self.async_check_and_refresh_token()
await self.hass.async_add_executor_job(
self.yoto_manager.play_card,
Expand Down
7 changes: 4 additions & 3 deletions custom_components/yoto/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ async def async_play_media(
**kwargs: Any,
) -> None:
cardid, chapterid, trackid = split_media_id(media_id)
_LOGGER.debug(
f"{DOMAIN} - Media requested: {media_id} Cardid: {cardid}, chapterid: {chapterid}, trackid: {trackid}"
)
await self.coordinator.async_play_card(
self.player.id, cardid, chapterid, trackid
player_id=self.player.id, cardid=cardid, chapter=chapterid, trackkey=trackid
)

async def async_set_volume_level(self, volume: float) -> None:
Expand All @@ -108,8 +111,6 @@ async def async_browse_media(
if media_content_id in (None, "library"):
return await self.async_convert_library_to_browse_media()
else:
_LOGGER.debug(f"{DOMAIN} - Getting chapters")

return await self.async_convert_chapter_to_browse_media(media_content_id)

async def async_convert_library_to_browse_media(self) -> list:
Expand Down

0 comments on commit c2cb00f

Please sign in to comment.