diff --git a/scripts/cast b/scripts/cast index 3311b02..adb4930 100755 --- a/scripts/cast +++ b/scripts/cast @@ -122,8 +122,7 @@ class Cast(wx.Frame): inner_sizer.Add(stop_button, FLAGS) inner_sizer.Add(back_button, FLAGS) - if not self.m_chromecast_thr.is_alive( - ) and not self.m_selected_chromecast: + if self.has_usable_chromecasts(): btm = make_bitmap_from_file( '{}/assets/Cast.png'.format(self.asset_path), wx.Size(24, 24)) cast_button = wx.BitmapButton(self.m_panel, @@ -191,6 +190,19 @@ class Cast(wx.Frame): 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: self.m_selected_provider_index = 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) 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, - id=-1, - label=friendly_name, - size=(WIDTH, BTN_HEIGHT)) + id=-1, + label=friendly_name, + size=(WIDTH, BTN_HEIGHT)) btn.Bind( wx.EVT_BUTTON, lambda event, chromecast=cast, muri=uri, cindex=channel_index: