|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
import hashlib
|
|
|
|
|
from typing import NewType
|
|
|
|
|
|
|
|
|
|
import wx
|
|
|
|
|
import wx.lib.scrolledpanel as scrolled
|
|
|
|
|
import wx.media
|
|
|
|
|
|
|
|
|
|
from ChannelProvider import SVT, ChannelProvider
|
|
|
|
@ -11,53 +11,84 @@ ChannelProvider = NewType('ChannelProvider', ChannelProvider)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Cast(wx.Frame):
|
|
|
|
|
m_channels: list[ChannelProvider] = list()
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
|
"""__init__.
|
|
|
|
|
:param args:
|
|
|
|
|
:param kw:
|
|
|
|
|
"""
|
|
|
|
|
super().__init__(*args, **kw)
|
|
|
|
|
self.m_channels.append(SVT.SVT())
|
|
|
|
|
self.m_index = 0
|
|
|
|
|
self.m_sizer: wx.Sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
self.m_panel: wx.lib.scrolledpanel.ScrolledPanel = scrolled.ScrolledPanel(
|
|
|
|
|
self, -1, style=wx.VSCROLL)
|
|
|
|
|
self.m_control = None
|
|
|
|
|
self.m_panel.SetupScrolling()
|
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
|
self.m_channels: list[ChannelProvider] = [SVT.SVT()]
|
|
|
|
|
self.show_list(None)
|
|
|
|
|
|
|
|
|
|
def show_list(self, _):
|
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
|
self.m_sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for channel in self.m_channels:
|
|
|
|
|
for item in channel.get_items():
|
|
|
|
|
title = wx.StaticText(self.m_panel, -1, item['title'])
|
|
|
|
|
description = wx.StaticText(self.m_panel, -1,
|
|
|
|
|
item['description'])
|
|
|
|
|
bitmap = item['thumbnail']
|
|
|
|
|
btn = wx.BitmapButton(self.m_panel, id=self.m_index, bitmap=bitmap)
|
|
|
|
|
btn.Bind(wx.EVT_BUTTON,
|
|
|
|
|
lambda event, link=item['link']: self.show_player(
|
|
|
|
|
event, link))
|
|
|
|
|
self.m_sizer.Add(title)
|
|
|
|
|
self.m_sizer.Add(btn)
|
|
|
|
|
self.m_sizer.Add(description)
|
|
|
|
|
self.m_index = self.m_index + 1
|
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
|
self.m_panel.Layout()
|
|
|
|
|
|
|
|
|
|
def show_player(self, _, uri):
|
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
|
self.m_sizer = wx.GridBagSizer()
|
|
|
|
|
self.m_control = wx.media.MediaCtrl(
|
|
|
|
|
self,
|
|
|
|
|
self.m_panel,
|
|
|
|
|
size=(480, 480),
|
|
|
|
|
style=wx.SIMPLE_BORDER,
|
|
|
|
|
szBackend=wx.media.MEDIABACKEND_GSTREAMER)
|
|
|
|
|
play_button = wx.Button(self, -1, "Play")
|
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.play, play_button)
|
|
|
|
|
|
|
|
|
|
pause_button = wx.Button(self, -1, "Pause")
|
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.pause, pause_button)
|
|
|
|
|
|
|
|
|
|
stop_button = wx.Button(self, -1, "Stop")
|
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.quit, stop_button)
|
|
|
|
|
|
|
|
|
|
sizer = wx.GridBagSizer()
|
|
|
|
|
sizer.Add(self.m_control, (0, 0))
|
|
|
|
|
sizer.SetItemSpan(0, (0, 6))
|
|
|
|
|
sizer.Add(play_button, (1, 1))
|
|
|
|
|
sizer.Add(pause_button, (1, 2))
|
|
|
|
|
sizer.Add(stop_button, (1, 3))
|
|
|
|
|
self.SetSizer(sizer)
|
|
|
|
|
|
|
|
|
|
self.m_control.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
|
|
|
|
|
self.m_control.Bind(wx.media.EVT_MEDIA_FINISHED, self.quit)
|
|
|
|
|
self.load_video(self.m_channels[0].get_items()[0]['link'])
|
|
|
|
|
self.Show(True)
|
|
|
|
|
sizer.Layout()
|
|
|
|
|
|
|
|
|
|
def load_video(self, uri):
|
|
|
|
|
play_button = wx.Button(self.m_panel, -1, "Play")
|
|
|
|
|
play_button.Bind(wx.EVT_BUTTON, self.play)
|
|
|
|
|
|
|
|
|
|
pause_button = wx.Button(self.m_panel, -1, "Pause")
|
|
|
|
|
pause_button.Bind(wx.EVT_BUTTON, self.pause)
|
|
|
|
|
|
|
|
|
|
back_button = wx.Button(self.m_panel, -1, "Back")
|
|
|
|
|
back_button.Bind(wx.EVT_BUTTON, self.show_list)
|
|
|
|
|
|
|
|
|
|
self.m_sizer.Add(self.m_control, (0, 0))
|
|
|
|
|
self.m_sizer.SetItemSpan(0, (0, 6))
|
|
|
|
|
self.m_sizer.Add(play_button, (1, 1))
|
|
|
|
|
self.m_sizer.Add(pause_button, (1, 2))
|
|
|
|
|
self.m_sizer.Add(back_button, (1, 3))
|
|
|
|
|
|
|
|
|
|
self.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
|
|
|
|
|
self.Bind(wx.media.EVT_MEDIA_FINISHED, self.show_list)
|
|
|
|
|
self.load_uri(uri)
|
|
|
|
|
self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
|
self.m_panel.Layout()
|
|
|
|
|
self.m_panel.ScrollChildIntoView(self.m_control)
|
|
|
|
|
|
|
|
|
|
def load_uri(self, uri):
|
|
|
|
|
self.m_control.LoadURI(uri)
|
|
|
|
|
|
|
|
|
|
def play(self, event):
|
|
|
|
|
def play(self, _):
|
|
|
|
|
self.m_control.Play()
|
|
|
|
|
|
|
|
|
|
def pause(self, event):
|
|
|
|
|
def pause(self, _):
|
|
|
|
|
self.m_control.Pause()
|
|
|
|
|
|
|
|
|
|
def quit(self, event):
|
|
|
|
|
def quit(self, _):
|
|
|
|
|
self.Destroy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|