Add support for running in single video mode

main
Micke Nordin 2 years ago
parent d90de29d4f
commit 6af864c5d6
Signed by: micke
GPG Key ID: 014B273D614BE877

@ -1,4 +1,5 @@
#!/usr/bin/env python3
import sys
import threading
import time
from typing import Callable
@ -32,6 +33,12 @@ class Cast(wx.Frame):
:param args:
: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)
self.m_selected_chromecast = None
self.SetSizeHints(WIDTH, HEIGHT, maxW=WIDTH)
@ -49,6 +56,9 @@ class Cast(wx.Frame):
self.m_panel.SetupScrolling(rate_y=SCROLL_RATE, scrollToTop=True)
self.m_panel.SetSizer(self.m_sizer)
self.m_providers: list[ChannelProvider] = self.get_providers()
if url:
self.show_player(None, url, 0)
else:
self.show_channel_list(None, 0)
def add_back_button(self, callback: Callable) -> None:
@ -79,6 +89,11 @@ class Cast(wx.Frame):
"Pause",
size=(WIDTH / 4, BTN_HEIGHT))
stop_button = wx.Button(self.m_panel,
-1,
"Stop",
size=(WIDTH / 4, BTN_HEIGHT))
if self.m_mode == 'normal':
back_button = wx.Button(self.m_panel,
-1,
"Back",
@ -88,15 +103,16 @@ class Cast(wx.Frame):
lambda event, cindex=channel_index: self.show_video_list(
event, cindex),
)
stop_button = wx.Button(self.m_panel,
else:
back_button = wx.Button(self.m_panel,
-1,
"Stop",
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(pause_button, FLAGS)
inner_sizer.Add(back_button, FLAGS)
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:
@ -388,7 +404,12 @@ class Cast(wx.Frame):
if __name__ == "__main__":
# When this module is run (not imported) then create the app, the
# frame, show it, and start the event loop.
url = None
app: wx.App = wx.App()
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()
app.MainLoop()

Loading…
Cancel
Save