Skip to content

Commit

Permalink
Add config entry for mp3 mode to google cast
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 23, 2024
1 parent 575534e commit 90e382a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion music_assistant/server/providers/chromecast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@
BASE_PLAYER_CONFIG_ENTRIES,
CONF_ENTRY_CROSSFADE_DURATION,
CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED,
CONF_ENTRY_ENFORCE_MP3,
ConfigEntry,
ConfigValueType,
create_sample_rates_config_entry,
)
from music_assistant.common.models.enums import MediaType, PlayerFeature, PlayerState, PlayerType
from music_assistant.common.models.errors import PlayerUnavailableError
from music_assistant.common.models.player import DeviceInfo, Player, PlayerMedia
from music_assistant.constants import CONF_PLAYERS, MASS_LOGO_ONLINE, VERBOSE_LOG_LEVEL
from music_assistant.constants import (
CONF_ENFORCE_MP3,
CONF_PLAYERS,
MASS_LOGO_ONLINE,
VERBOSE_LOG_LEVEL,
)
from music_assistant.server.models.player_provider import PlayerProvider

from .helpers import CastStatusListener, ChromecastInfo
Expand All @@ -48,6 +54,7 @@
PLAYER_CONFIG_ENTRIES = (
CONF_ENTRY_CROSSFADE_FLOW_MODE_REQUIRED,
CONF_ENTRY_CROSSFADE_DURATION,
CONF_ENTRY_ENFORCE_MP3,
)

# originally/officially cast supports 96k sample rate (even for groups)
Expand Down Expand Up @@ -241,6 +248,8 @@ async def play_media(
) -> None:
"""Handle PLAY MEDIA on given player."""
castplayer = self.castplayers[player_id]
if self.mass.config.get_raw_player_config_value(player_id, CONF_ENFORCE_MP3, False):
media.uri = media.uri.replace(".flac", ".mp3")
queuedata = {
"type": "LOAD",
"media": self._create_cc_media_item(media),
Expand All @@ -254,6 +263,8 @@ async def play_media(
async def enqueue_next_media(self, player_id: str, media: PlayerMedia) -> None:
"""Handle enqueuing of the next item on the player."""
castplayer = self.castplayers[player_id]
if self.mass.config.get_raw_player_config_value(player_id, CONF_ENFORCE_MP3, False):
media.uri = media.uri.replace(".flac", ".mp3")
next_item_id = None
status = castplayer.cc.media_controller.status
# lookup position of current track in cast queue
Expand Down

0 comments on commit 90e382a

Please sign in to comment.