|
|
@ -1,4 +1,5 @@
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import threading
|
|
|
|
import threading
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
from typing import Callable
|
|
|
|
from typing import Callable
|
|
|
@ -32,6 +33,12 @@ class Cast(wx.Frame):
|
|
|
|
:param args:
|
|
|
|
:param args:
|
|
|
|
:param kw:
|
|
|
|
:param kw:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.m_mode = 'normal'
|
|
|
|
|
|
|
|
url = None
|
|
|
|
|
|
|
|
if "url" in kw:
|
|
|
|
|
|
|
|
self.m_mode = 'single'
|
|
|
|
|
|
|
|
url = kw['url']
|
|
|
|
|
|
|
|
del kw['url']
|
|
|
|
super().__init__(*args, **kw)
|
|
|
|
super().__init__(*args, **kw)
|
|
|
|
self.m_selected_chromecast = None
|
|
|
|
self.m_selected_chromecast = None
|
|
|
|
self.SetSizeHints(WIDTH, HEIGHT, maxW=WIDTH)
|
|
|
|
self.SetSizeHints(WIDTH, HEIGHT, maxW=WIDTH)
|
|
|
@ -49,7 +56,10 @@ class Cast(wx.Frame):
|
|
|
|
self.m_panel.SetupScrolling(rate_y=SCROLL_RATE, scrollToTop=True)
|
|
|
|
self.m_panel.SetupScrolling(rate_y=SCROLL_RATE, scrollToTop=True)
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
self.m_providers: list[ChannelProvider] = self.get_providers()
|
|
|
|
self.m_providers: list[ChannelProvider] = self.get_providers()
|
|
|
|
self.show_channel_list(None, 0)
|
|
|
|
if url:
|
|
|
|
|
|
|
|
self.show_player(None, url, 0)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.show_channel_list(None, 0)
|
|
|
|
|
|
|
|
|
|
|
|
def add_back_button(self, callback: Callable) -> None:
|
|
|
|
def add_back_button(self, callback: Callable) -> None:
|
|
|
|
backbtn = wx.Button(self.m_panel,
|
|
|
|
backbtn = wx.Button(self.m_panel,
|
|
|
@ -79,24 +89,30 @@ class Cast(wx.Frame):
|
|
|
|
"Pause",
|
|
|
|
"Pause",
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
|
|
|
|
|
|
|
|
back_button = wx.Button(self.m_panel,
|
|
|
|
|
|
|
|
-1,
|
|
|
|
|
|
|
|
"Back",
|
|
|
|
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
|
|
|
|
back_button.Bind(
|
|
|
|
|
|
|
|
wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
lambda event, cindex=channel_index: self.show_video_list(
|
|
|
|
|
|
|
|
event, cindex),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop_button = wx.Button(self.m_panel,
|
|
|
|
stop_button = wx.Button(self.m_panel,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
"Stop",
|
|
|
|
"Stop",
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
|
|
|
|
if self.m_mode == 'normal':
|
|
|
|
|
|
|
|
back_button = wx.Button(self.m_panel,
|
|
|
|
|
|
|
|
-1,
|
|
|
|
|
|
|
|
"Back",
|
|
|
|
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
|
|
|
|
back_button.Bind(
|
|
|
|
|
|
|
|
wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
lambda event, cindex=channel_index: self.show_video_list(
|
|
|
|
|
|
|
|
event, cindex),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
back_button = wx.Button(self.m_panel,
|
|
|
|
|
|
|
|
-1,
|
|
|
|
|
|
|
|
label="Close",
|
|
|
|
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
|
|
|
|
back_button.Bind(wx.EVT_BUTTON, lambda event: self.Destroy())
|
|
|
|
inner_sizer.Add(play_button, FLAGS)
|
|
|
|
inner_sizer.Add(play_button, FLAGS)
|
|
|
|
inner_sizer.Add(pause_button, FLAGS)
|
|
|
|
inner_sizer.Add(pause_button, FLAGS)
|
|
|
|
inner_sizer.Add(back_button, FLAGS)
|
|
|
|
|
|
|
|
inner_sizer.Add(stop_button, FLAGS)
|
|
|
|
inner_sizer.Add(stop_button, FLAGS)
|
|
|
|
|
|
|
|
inner_sizer.Add(back_button, FLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
if not self.m_chromecast_thr.is_alive(
|
|
|
|
if not self.m_chromecast_thr.is_alive(
|
|
|
|
) and not self.m_selected_chromecast:
|
|
|
|
) and not self.m_selected_chromecast:
|
|
|
@ -388,7 +404,12 @@ class Cast(wx.Frame):
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# When this module is run (not imported) then create the app, the
|
|
|
|
# When this module is run (not imported) then create the app, the
|
|
|
|
# frame, show it, and start the event loop.
|
|
|
|
# frame, show it, and start the event loop.
|
|
|
|
|
|
|
|
url = None
|
|
|
|
app: wx.App = wx.App()
|
|
|
|
app: wx.App = wx.App()
|
|
|
|
frm: Cast = Cast(None, title="Cast")
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
|
|
|
|
url = sys.argv[1]
|
|
|
|
|
|
|
|
frm: Cast = Cast(None, title="Cast", url=url)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
frm: Cast = Cast(None, title="Cast")
|
|
|
|
frm.Show()
|
|
|
|
frm.Show()
|
|
|
|
app.MainLoop()
|
|
|
|
app.MainLoop()
|
|
|
|