Skip to content

Commit

Permalink
Update music_caster.py
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
elibroftw committed Nov 15, 2019
1 parent fb6b790 commit 810e323
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions music_caster.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ def play_file(file_path, position=0, autoplay=True, switching_device=False):
local_music_player.init(sampling_rate, -16, 2, 2048)
local_music_player.music.load(file_path)
local_music_player.music.set_volume(volume)
local_music_player.music.play(start=position)
local_music_player.music.play(start=song_position)
if not autoplay: local_music_player.music.pause()
song_start = time.time() - song_position
song_end = song_start + song_length - position
song_end = song_start + song_length - song_position
else:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand Down Expand Up @@ -323,11 +323,12 @@ def play_file(file_path, position=0, autoplay=True, switching_device=False):
mc.stop()
mc.block_until_active(5)
music_metadata = {'metadataType': 3, 'albumName': album, 'title': title, 'artist': artist}
mc.play_media(url, 'audio/mp3', current_time=position, metadata=music_metadata, thumb=thumb, autoplay=autoplay)
mc.play_media(url, 'audio/mp3', current_time=song_position, metadata=music_metadata, thumb=thumb,
autoplay=autoplay)
mc.block_until_active()
while not mc.is_playing: pass
song_start = time.time()
song_end = song_start + song_length - position
song_start = time.time() - song_position
song_end = song_start + song_length - song_position
except (pychromecast.error.NotConnected, OSError):
tray.ShowMessage('Music Caster', 'Could not connect to Chromecast device')
with suppress(pychromecast.error.UnsupportedNamespace): stop()
Expand Down

0 comments on commit 810e323

Please sign in to comment.