我正在编写一个 wx.Python 代码,用于在按下按钮时播放视频(有效)。如果按下另一个按钮,则会播放另一个视频(有效)。
但是,在加载第二个视频时会出现 2(ish)秒的黑屏。有没有办法让它立即加载和播放而不是黑屏转换?
def onTestClick(self, media):
#array = 2
#if already playing, button press, next vid becomes 0, preload next vid, delay 1.6sec, play.
self.vidqueue = ["", ""]
self.vidqueue [0] = "Null"
self.vidqueue [1] = media
if self.vidqueue[0] == "Null":
self.vidqueue [0] = self.vidqueue [1]
print (self.vidqueue[0])
self.testMedia = wx.media.MediaCtrl(self, size = (500, 300), style=wx.SIMPLE_BORDER, szBackend = wx.media.MEDIABACKEND_WMP10)
self.testMedia.Load(self.vidqueue [0])
self.testMedia.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
self.testMedia.Bind(wx.media.EVT_MEDIA_FINISHED, self.quit)
self.Bind(wx.EVT_BUTTON, self.addVid1, addBtn1)
self.Bind(wx.EVT_BUTTON, self.addVid2, addBtn2)
def buttonPressed1(self, event):
file1 = filePathList[0]
self.refTop.onTestClick(file1)
def buttonPressed2(self, event):
file2 = filePathList[1]
self.refTop.onTestClick(file2)
def play(self, event):
self.testMedia.Play()
self.vidqueue [0] = "Null"
def quit(self, event):
self.testMedia.Destroy()