You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cast/main.py

71 lines
1.9 KiB

#!/usr/bin/env python3
import hashlib
from typing import NewType
import wx
import wx.media
from ChannelProvider import SVT, ChannelProvider
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_control = wx.media.MediaCtrl(
self,
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):
self.m_control.LoadURI(uri)
def play(self, event):
self.m_control.Play()
def pause(self, event):
self.m_control.Pause()
def quit(self, event):
self.Destroy()
if __name__ == '__main__':
# When this module is run (not imported) then create the app, the
# frame, show it, and start the event loop.
app: wx.App = wx.App()
frm: Cast = Cast(None, title='Cast')
frm.Show()
app.MainLoop()