Skip to content

Commit

Permalink
Experiment with update_cast to improve connection issues
Browse files Browse the repository at this point in the history
  • Loading branch information
elibroftw committed May 9, 2024
1 parent 443ac66 commit a8274e8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Music Caster by Elijah Lopez Changelog

5.19.11
- [Experiment] Better connection?

5.19.10
- [Fix] Unexpected crash - chromecast related

Expand Down
8 changes: 4 additions & 4 deletions build_files/mc_version_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# For more details about fixed file info 'ffi' see: http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
prodvers=(5, 19, 10, 0),
filevers=(5, 19, 10, 0),
prodvers=(5, 19, 11, 0),
filevers=(5, 19, 11, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x17,
# Contains a bitmask that specifies the Boolean attributes of the file.
Expand All @@ -27,12 +27,12 @@ VSVersionInfo(
'000004b0',
[StringStruct('CompanyName', 'Elijah Lopez'),
StringStruct('FileDescription', 'Music Caster'),
StringStruct('FileVersion', '5.19.10.0'),
StringStruct('FileVersion', '5.19.11.0'),
StringStruct('InternalName', 'Music Caster'),
StringStruct('LegalCopyright', 'Copyright (c) 2019 - 2024, Elijah Lopez'),
StringStruct('OriginalFilename', 'Music Caster.exe'),
StringStruct('ProductName', 'Music Caster'),
StringStruct('ProductVersion', '5.19.10.0')])
StringStruct('ProductVersion', '5.19.11.0')])
]),
VarFileInfo([VarStruct('Translation', [0, 1200])])
]
Expand Down
2 changes: 1 addition & 1 deletion build_files/setup_script.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MyAppName "Music Caster"
#define MyAppVersion "5.19.10"
#define MyAppVersion "5.19.11"
#define MyAppPublisher "Elijah Lopez"
#define MyAppURL "https://elijahlopez.ca/software#music-caster"
#define MyAppExeName "Music Caster.exe"
Expand Down
2 changes: 1 addition & 1 deletion src/meta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = latest_version = '5.19.10'
VERSION = latest_version = '5.19.11'
UPDATE_MESSAGE = """
[NEW] Better Error Capturing
[MSG] Language translators wanted
Expand Down
18 changes: 15 additions & 3 deletions src/music_caster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ def load_media_failed(self, item, error_code):

class MyCastListener(pychromecast.discovery.AbstractCastListener):

def add_cast(self, uuid, _service):
def add_cast(self, uuid, _service: str):
"""Called when a new cast has been discovered."""
print(f'cast found found {uuid}')
global cast
Expand All @@ -1218,16 +1218,28 @@ def add_cast(self, uuid, _service):
# cast.media_controller.register_status_listener(MediaCastListener(cast))
refresh_tray(True)

def remove_cast(self, uuid, _service, cast_info):
def remove_cast(self, uuid, _service: str, cast_info):
"""Called when a cast has been lost (MDNS info expired or host down)."""
global cast
if cast is not None and cast.uuid == uuid:
# lost connection to connected device
app_log.info(f'Lost connection to {cast.name} ({uuid}), switching to local device')
refresh_tray(True)

def update_cast(self, uuid, _service):
def update_cast(self, uuid, _service: str):
"""Called when a cast has been updated (MDNS info renewed or changed)."""
global cast
# not entirely sure what to do if this function is called
# due to recent connection errors, let's experiment
# if we should update the cast variable?
if cast is not None and cast.uuid == uuid:
cast_info = cast_browser.devices[uuid]
cast_2 = pychromecast.get_chromecast_from_cast_info(cast_info, zconf=zconf)
try:
assert cast_2 == cast
except AssertionError as e:
handle_exception(e)
cast = cast_2
refresh_tray(True)


Expand Down

0 comments on commit a8274e8

Please sign in to comment.