|
|
@ -12,7 +12,8 @@ from vlc import Instance
|
|
|
|
|
|
|
|
|
|
|
|
from Channel import SVT
|
|
|
|
from Channel import SVT
|
|
|
|
from ChannelProvider import ChannelProvider
|
|
|
|
from ChannelProvider import ChannelProvider
|
|
|
|
from Utils import make_bitmap_from_file, make_sized_button
|
|
|
|
from Utils import (get_all_svt_categories, make_bitmap_from_file,
|
|
|
|
|
|
|
|
make_sized_button)
|
|
|
|
|
|
|
|
|
|
|
|
WIDTH = int(720 / 2)
|
|
|
|
WIDTH = int(720 / 2)
|
|
|
|
HEIGHT = int(1440 / 2)
|
|
|
|
HEIGHT = int(1440 / 2)
|
|
|
@ -28,6 +29,7 @@ FLAGS.Center()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Cast(wx.Frame):
|
|
|
|
class Cast(wx.Frame):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
"""__init__.
|
|
|
|
"""__init__.
|
|
|
|
:param args:
|
|
|
|
:param args:
|
|
|
@ -91,9 +93,9 @@ class Cast(wx.Frame):
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
|
|
|
|
|
|
|
|
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':
|
|
|
|
if self.m_mode == 'normal':
|
|
|
|
back_button = wx.Button(self.m_panel,
|
|
|
|
back_button = wx.Button(self.m_panel,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
@ -106,9 +108,9 @@ class Cast(wx.Frame):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
back_button = wx.Button(self.m_panel,
|
|
|
|
back_button = wx.Button(self.m_panel,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
label="Close",
|
|
|
|
label="Close",
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
size=(WIDTH / 4, BTN_HEIGHT))
|
|
|
|
back_button.Bind(wx.EVT_BUTTON, lambda event: self.Destroy())
|
|
|
|
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)
|
|
|
@ -117,7 +119,8 @@ class Cast(wx.Frame):
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
btm = make_bitmap_from_file('{}/assets/Cast.png'.format(self.asset_path), wx.Size(24,24))
|
|
|
|
btm = make_bitmap_from_file(
|
|
|
|
|
|
|
|
'{}/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,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
bitmap=btm,
|
|
|
|
bitmap=btm,
|
|
|
@ -129,7 +132,6 @@ class Cast(wx.Frame):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
inner_sizer.Add(cast_button, FLAGS)
|
|
|
|
inner_sizer.Add(cast_button, FLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.m_selected_chromecast:
|
|
|
|
if self.m_selected_chromecast:
|
|
|
|
self.cast(wx.media.EVT_MEDIA_LOADED, uri),
|
|
|
|
self.cast(wx.media.EVT_MEDIA_LOADED, uri),
|
|
|
|
play_button.Bind(wx.EVT_BUTTON, self.play_cast)
|
|
|
|
play_button.Bind(wx.EVT_BUTTON, self.play_cast)
|
|
|
@ -153,33 +155,31 @@ class Cast(wx.Frame):
|
|
|
|
def get_providers(self) -> list[ChannelProvider]:
|
|
|
|
def get_providers(self) -> list[ChannelProvider]:
|
|
|
|
|
|
|
|
|
|
|
|
providers = list()
|
|
|
|
providers = list()
|
|
|
|
svt = ChannelProvider(
|
|
|
|
channels: list = list()
|
|
|
|
"SVT",
|
|
|
|
ids = [
|
|
|
|
channels=[
|
|
|
|
"feed", "ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen",
|
|
|
|
SVT.SVT("feed"),
|
|
|
|
"ch-kunskapskanalen", "allprograms"
|
|
|
|
SVT.SVT("ch-svt1"),
|
|
|
|
]
|
|
|
|
SVT.SVT("ch-svt2"),
|
|
|
|
|
|
|
|
SVT.SVT("ch-svt24"),
|
|
|
|
for category in get_all_svt_categories():
|
|
|
|
SVT.SVT("ch-barnkanalen"),
|
|
|
|
ids.append(category['id'])
|
|
|
|
SVT.SVT("ch-kunskapskanalen"),
|
|
|
|
for id in ids:
|
|
|
|
SVT.SVT("allprograms"),
|
|
|
|
channels.append(SVT.SVT(id))
|
|
|
|
],
|
|
|
|
svt = ChannelProvider("SVT", channels=channels)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
providers.append(svt)
|
|
|
|
providers.append(svt)
|
|
|
|
|
|
|
|
|
|
|
|
return providers
|
|
|
|
return providers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
closebtn = wx.Button(self.m_panel,
|
|
|
|
closebtn = wx.Button(self.m_panel,
|
|
|
|
-1,
|
|
|
|
-1,
|
|
|
|
label="Close",
|
|
|
|
label="Close",
|
|
|
|
size=(WIDTH, BTN_HEIGHT))
|
|
|
|
size=(WIDTH, BTN_HEIGHT))
|
|
|
|
closebtn.Bind(wx.EVT_BUTTON, lambda event: self.Destroy())
|
|
|
|
closebtn.Bind(wx.EVT_BUTTON, lambda event: self.Destroy())
|
|
|
|
self.m_sizer.Add(closebtn, 0, wx.ALL, 1)
|
|
|
|
self.m_sizer.Add(closebtn, 0, wx.ALL, 1)
|
|
|
|
|
|
|
|
|
|
|
@ -209,7 +209,11 @@ class Cast(wx.Frame):
|
|
|
|
back_callback = lambda event: self.show_channel_list(
|
|
|
|
back_callback = lambda event: self.show_channel_list(
|
|
|
|
event, self.m_selected_provider_index)
|
|
|
|
event, self.m_selected_provider_index)
|
|
|
|
self.add_back_button(back_callback)
|
|
|
|
self.add_back_button(back_callback)
|
|
|
|
if self.m_selected_provider.get_name() == 'SVT' and self.m_selected_channel.get_id() == 'feed':
|
|
|
|
if self.m_selected_provider.get_name(
|
|
|
|
|
|
|
|
) == 'SVT' and self.m_selected_channel.get_id() not in [
|
|
|
|
|
|
|
|
"ch-svt1", "ch-svt2", "ch-svt24", "ch-barnkanalen",
|
|
|
|
|
|
|
|
"ch-kunskapskanalen"
|
|
|
|
|
|
|
|
]:
|
|
|
|
|
|
|
|
|
|
|
|
def refresh_callback(event):
|
|
|
|
def refresh_callback(event):
|
|
|
|
self.m_selected_channel.refresh()
|
|
|
|
self.m_selected_channel.refresh()
|
|
|
@ -224,9 +228,13 @@ class Cast(wx.Frame):
|
|
|
|
|
|
|
|
|
|
|
|
if self.m_selected_channel.wait():
|
|
|
|
if self.m_selected_channel.wait():
|
|
|
|
with wx.BusyInfo("Please wait, working..."):
|
|
|
|
with wx.BusyInfo("Please wait, working..."):
|
|
|
|
|
|
|
|
number_of_waits = 0
|
|
|
|
while self.m_selected_channel.wait():
|
|
|
|
while self.m_selected_channel.wait():
|
|
|
|
|
|
|
|
number_of_waits += 1
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
wx.GetApp().Yield()
|
|
|
|
wx.GetApp().Yield()
|
|
|
|
|
|
|
|
if number_of_waits > 10:
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
btnindex = 0
|
|
|
|
btnindex = 0
|
|
|
|
for item in self.m_selected_channel.get_items(): # type: ignore
|
|
|
|
for item in self.m_selected_channel.get_items(): # type: ignore
|
|
|
|