Various fixes for chromecasts

main
Micke Nordin 2 years ago
parent fc0a26c74e
commit 60ab02b4ba

@ -122,8 +122,7 @@ class Cast(wx.Frame):
inner_sizer.Add(stop_button, FLAGS) inner_sizer.Add(stop_button, FLAGS)
inner_sizer.Add(back_button, FLAGS) inner_sizer.Add(back_button, FLAGS)
if not self.m_chromecast_thr.is_alive( if self.has_usable_chromecasts():
) and not self.m_selected_chromecast:
btm = make_bitmap_from_file( btm = make_bitmap_from_file(
'{}/assets/Cast.png'.format(self.asset_path), wx.Size(24, 24)) '{}/assets/Cast.png'.format(self.asset_path), wx.Size(24, 24))
cast_button = wx.BitmapButton(self.m_panel, cast_button = wx.BitmapButton(self.m_panel,
@ -191,6 +190,19 @@ class Cast(wx.Frame):
return providers return providers
def has_usable_chromecasts(self) -> bool:
if self.m_chromecast_thr.is_alive():
return False
if self.m_selected_chromecast:
return False
result = False
for cast in self.m_chromecasts:
if cast.cast_type != 'audio':
result = True
break
return result
def show_channel_list(self, _, provider_index) -> None: def show_channel_list(self, _, provider_index) -> None:
self.m_selected_provider_index = provider_index self.m_selected_provider_index = provider_index
self.m_selected_provider = self.m_providers[provider_index] self.m_selected_provider = self.m_providers[provider_index]
@ -375,11 +387,17 @@ class Cast(wx.Frame):
self.m_sizer.Add(cancel_btn) self.m_sizer.Add(cancel_btn)
for cast in self.m_chromecasts: for cast in self.m_chromecasts:
friendly_name = cast.device.friendly_name if cast.cast_type == 'audio':
continue
friendly_name = "Unknown Chromecast"
try:
friendly_name = cast.device.friendly_name
except AttributeError:
friendly_name = cast.cast_info.friendly_name
btn = wx.Button(self.m_panel, btn = wx.Button(self.m_panel,
id=-1, id=-1,
label=friendly_name, label=friendly_name,
size=(WIDTH, BTN_HEIGHT)) size=(WIDTH, BTN_HEIGHT))
btn.Bind( btn.Bind(
wx.EVT_BUTTON, wx.EVT_BUTTON,
lambda event, chromecast=cast, muri=uri, cindex=channel_index: lambda event, chromecast=cast, muri=uri, cindex=channel_index:

Loading…
Cancel
Save