Skip to content

Commit 70e6676

Browse files
committed
Increase wait timeout when play is called
1 parent 8e452ee commit 70e6676

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/music_caster.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ def play(position=0, autoplay=True, switching_device=False, show_error=False, fr
21642164
url = f'http://{get_ipv4()}:{State.PORT}/file?{url_args}'
21652165
app_log.info(f'calling cast.wait on device {cast.cast_info.friendly_name} / {cast.uuid}')
21662166
app_log.info(f'cast.media_controller player state: {cast.media_controller.status.player_state}')
2167-
cast.wait(timeout=WAIT_TIMEOUT)
2167+
cast.wait(timeout=15 if show_error else WAIT_TIMEOUT)
21682168
if not from_set_pos:
21692169
app_log.info(f'try: cast.set_volume({volume})')
21702170
with suppress(RequestTimeout):
@@ -2174,6 +2174,7 @@ def play(position=0, autoplay=True, switching_device=False, show_error=False, fr
21742174
metadata = {'title': str(metadata['title']), 'artist': str(metadata['artist']),
21752175
'albumName': str(metadata['album']), 'metadataType': 3}
21762176
ext = uri.split('.')[-1]
2177+
# pychromecast.error.NotConnected: Chromecast unknown:8009 is connecting..
21772178
mc.play_media(url, f'audio/{ext}', current_time=position,
21782179
metadata=metadata, thumb=f'{url}&thumbnail_only=true', autoplay=autoplay)
21792180
mc.block_until_active(WAIT_TIMEOUT)
@@ -2217,8 +2218,8 @@ def play(position=0, autoplay=True, switching_device=False, show_error=False, fr
22172218
if cast.media_controller.status.player_state == 'UNKNOWN':
22182219
try:
22192220
cast.media_controller.stop()
2220-
cast.quit_app(10)
2221-
cast.wait(10)
2221+
cast.quit_app(15)
2222+
cast.wait(15)
22222223
try_reconnecting = False
22232224
except PyChromecastError as e:
22242225
app_log.error('failed to stop, quit, or wait on cast device', exc_info=True)

0 commit comments

Comments
 (0)