|
|
@ -1,4 +1,5 @@
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import mpv
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import threading
|
|
|
|
import threading
|
|
|
@ -271,59 +272,78 @@ class Cast(wx.Frame):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
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)
|
|
|
|
# self.m_sizer.AddSpacer(SPACER_HEIGHT * 4)
|
|
|
|
#inner_sizer = wx.GridBagSizer()
|
|
|
|
inner_sizer = wx.GridBagSizer()
|
|
|
|
window = wx.Window(self.m_panel,
|
|
|
|
self.m_control = wx.media.MediaCtrl(
|
|
|
|
|
|
|
|
self.m_panel,
|
|
|
|
|
|
|
|
size=(WIDTH, int(HEIGHT / 2)),
|
|
|
|
size=(WIDTH, int(HEIGHT / 2)),
|
|
|
|
style=wx.SIMPLE_BORDER,
|
|
|
|
|
|
|
|
szBackend=wx.media.MEDIABACKEND_GSTREAMER,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
play_button = wx.Button(self.m_panel, -1, "Play")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pause_button = wx.Button(self.m_panel, -1, "Pause")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
back_button = wx.Button(self.m_panel, -1, "Back")
|
|
|
|
|
|
|
|
back_button.Bind(
|
|
|
|
|
|
|
|
wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
lambda event, cindex=channel_index: self.show_video_list(event, cindex),
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
self.m_sizer.Add(window)
|
|
|
|
inner_sizer.Add(self.m_control, (0, 0))
|
|
|
|
player = mpv.MPV(ytdl=False,player_operation_mode='pseudo-gui',
|
|
|
|
inner_sizer.SetItemSpan(0, (0, 6))
|
|
|
|
script_opts='osc-layout=box,osc-seekbarstyle=bar,osc-deadzonesize=0,osc-minmousemove=3',
|
|
|
|
inner_sizer.Add(play_button, (1, 1))
|
|
|
|
input_default_bindings=True,
|
|
|
|
inner_sizer.Add(pause_button, (1, 2))
|
|
|
|
input_vo_keyboard=True,
|
|
|
|
inner_sizer.Add(back_button, (1, 3))
|
|
|
|
osc=True)
|
|
|
|
|
|
|
|
#player = mpv.MPV(ytdl=True, input_default_bindings=True, input_vo_keyboard=True, osc=True, wid=str(window.GetId()))
|
|
|
|
if not self.m_chromecast_thr.is_alive(
|
|
|
|
|
|
|
|
) and not self.m_selected_chromecast:
|
|
|
|
|
|
|
|
chromecast_button = wx.Button(self.m_panel, -1, "Cast")
|
|
|
|
|
|
|
|
chromecast_button.Bind(
|
|
|
|
|
|
|
|
wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
lambda event, muri=uri, cindex=channel_index: self.select_chromecast(event, muri, cindex),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
inner_sizer.Add(chromecast_button, (2, 2))
|
|
|
|
|
|
|
|
self.m_sizer.Add(inner_sizer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.m_selected_chromecast:
|
|
|
|
|
|
|
|
self.Bind(
|
|
|
|
|
|
|
|
wx.media.EVT_MEDIA_LOADED,
|
|
|
|
|
|
|
|
lambda event, muri=uri: self.cast(event, muri),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
play_button.Bind(wx.EVT_BUTTON, self.play_cast)
|
|
|
|
|
|
|
|
pause_button.Bind(wx.EVT_BUTTON, self.pause_cast)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
|
|
|
|
|
|
|
|
play_button.Bind(wx.EVT_BUTTON, self.play)
|
|
|
|
|
|
|
|
pause_button.Bind(wx.EVT_BUTTON, self.pause)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.Bind(wx.media.EVT_MEDIA_FINISHED, lambda event: self.show_video_list(event,0))
|
|
|
|
|
|
|
|
self.load_uri(uri)
|
|
|
|
|
|
|
|
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_sizer.Fit(self)
|
|
|
|
self.m_sizer.Fit(self)
|
|
|
|
self.m_sizer.Layout()
|
|
|
|
self.m_sizer.Layout()
|
|
|
|
self.m_panel.ScrollChildIntoView(self.m_control)
|
|
|
|
try:
|
|
|
|
|
|
|
|
player.play(uri)
|
|
|
|
|
|
|
|
player.wait_for_playback()
|
|
|
|
|
|
|
|
except mpv.ShutdownError:
|
|
|
|
|
|
|
|
player.terminate()
|
|
|
|
|
|
|
|
del player
|
|
|
|
|
|
|
|
self.show_video_list(None,0)
|
|
|
|
|
|
|
|
#self.m_control = wx.media.MediaCtrl(
|
|
|
|
|
|
|
|
# self.m_panel,
|
|
|
|
|
|
|
|
# size=(WIDTH, int(HEIGHT / 2)),
|
|
|
|
|
|
|
|
# style=wx.SIMPLE_BORDER,
|
|
|
|
|
|
|
|
# szBackend=wx.media.MEDIABACKEND_GSTREAMER,
|
|
|
|
|
|
|
|
#)
|
|
|
|
|
|
|
|
#play_button = wx.Button(self.m_panel, -1, "Play")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pause_button = wx.Button(self.m_panel, -1, "Pause")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#back_button = wx.Button(self.m_panel, -1, "Back")
|
|
|
|
|
|
|
|
#back_button.Bind(
|
|
|
|
|
|
|
|
# wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
# lambda event, cindex=channel_index: self.show_video_list(event, cindex),
|
|
|
|
|
|
|
|
#)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#inner_sizer.Add(self.m_control, (0, 0))
|
|
|
|
|
|
|
|
#inner_sizer.SetItemSpan(0, (0, 6))
|
|
|
|
|
|
|
|
#inner_sizer.Add(play_button, (1, 1))
|
|
|
|
|
|
|
|
#inner_sizer.Add(pause_button, (1, 2))
|
|
|
|
|
|
|
|
#inner_sizer.Add(back_button, (1, 3))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if not self.m_chromecast_thr.is_alive(
|
|
|
|
|
|
|
|
#) and not self.m_selected_chromecast:
|
|
|
|
|
|
|
|
# chromecast_button = wx.Button(self.m_panel, -1, "Cast")
|
|
|
|
|
|
|
|
# chromecast_button.Bind(
|
|
|
|
|
|
|
|
# wx.EVT_BUTTON,
|
|
|
|
|
|
|
|
# lambda event, muri=uri, cindex=channel_index: self.select_chromecast(event, muri, cindex),
|
|
|
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
# inner_sizer.Add(chromecast_button, (2, 2))
|
|
|
|
|
|
|
|
#self.m_sizer.Add(inner_sizer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if self.m_selected_chromecast:
|
|
|
|
|
|
|
|
# self.Bind(
|
|
|
|
|
|
|
|
# wx.media.EVT_MEDIA_LOADED,
|
|
|
|
|
|
|
|
# lambda event, muri=uri: self.cast(event, muri),
|
|
|
|
|
|
|
|
# )
|
|
|
|
|
|
|
|
# play_button.Bind(wx.EVT_BUTTON, self.play_cast)
|
|
|
|
|
|
|
|
# pause_button.Bind(wx.EVT_BUTTON, self.pause_cast)
|
|
|
|
|
|
|
|
#else:
|
|
|
|
|
|
|
|
# self.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
|
|
|
|
|
|
|
|
# play_button.Bind(wx.EVT_BUTTON, self.play)
|
|
|
|
|
|
|
|
# pause_button.Bind(wx.EVT_BUTTON, self.pause)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#self.Bind(wx.media.EVT_MEDIA_FINISHED, lambda event: self.show_video_list(event,0))
|
|
|
|
|
|
|
|
#self.load_uri(uri)
|
|
|
|
|
|
|
|
#self.m_panel.SetupScrolling(rate_y=SCROLL_RATE, scrollToTop=True)
|
|
|
|
|
|
|
|
#self.m_panel.SetSizer(self.m_sizer)
|
|
|
|
|
|
|
|
#self.m_sizer.Fit(self)
|
|
|
|
|
|
|
|
#self.m_sizer.Layout()
|
|
|
|
|
|
|
|
#self.m_panel.ScrollChildIntoView(self.m_control)
|
|
|
|
|
|
|
|
|
|
|
|
def select_chromecast(self, _, uri, channel_index):
|
|
|
|
def select_chromecast(self, _, uri, channel_index):
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|
self.m_sizer.Clear(delete_windows=True)
|
|
|
|