This commit was manufactured by cvs2svn to create tag 'WX_2_6_3'.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WX_2_6_3@38365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3,7 +3,17 @@ import wx
|
||||
import wx.media
|
||||
import os
|
||||
|
||||
from Main import opj
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class StaticText(wx.StaticText):
|
||||
"""
|
||||
A StaticText that only updates the label if it has changed, to
|
||||
help reduce potential flicker since these controls would be
|
||||
updated very frequently otherwise.
|
||||
"""
|
||||
def SetLabel(self, label):
|
||||
if label <> self.GetLabel():
|
||||
wx.StaticText.SetLabel(self, label)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@@ -20,11 +30,14 @@ class TestPanel(wx.Panel):
|
||||
self.Destroy()
|
||||
raise
|
||||
|
||||
self.Bind(wx.media.EVT_MEDIA_LOADED, self.OnMediaLoaded)
|
||||
|
||||
btn1 = wx.Button(self, -1, "Load File")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn1)
|
||||
|
||||
btn2 = wx.Button(self, -1, "Play")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnPlay, btn2)
|
||||
self.playBtn = btn2
|
||||
|
||||
btn3 = wx.Button(self, -1, "Pause")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnPause, btn3)
|
||||
@@ -34,11 +47,12 @@ class TestPanel(wx.Panel):
|
||||
|
||||
slider = wx.Slider(self, -1, 0, 0, 0)
|
||||
self.slider = slider
|
||||
slider.SetMinSize((150, -1))
|
||||
self.Bind(wx.EVT_SLIDER, self.OnSeek, slider)
|
||||
|
||||
self.st_size = wx.StaticText(self, -1, size=(100,-1))
|
||||
self.st_len = wx.StaticText(self, -1, size=(100,-1))
|
||||
self.st_pos = wx.StaticText(self, -1, size=(100,-1))
|
||||
self.st_size = StaticText(self, -1, size=(100,-1))
|
||||
self.st_len = StaticText(self, -1, size=(100,-1))
|
||||
self.st_pos = StaticText(self, -1, size=(100,-1))
|
||||
|
||||
|
||||
# setup the layout
|
||||
@@ -54,8 +68,8 @@ class TestPanel(wx.Panel):
|
||||
sizer.Add(self.st_pos, (3, 5))
|
||||
self.SetSizer(sizer)
|
||||
|
||||
self.DoLoadFile(opj("data/testmovie.mpg"))
|
||||
self.mc.Stop()
|
||||
#self.DoLoadFile(os.path.abspath("data/testmovie.mpg"))
|
||||
wx.CallAfter(self.DoLoadFile, os.path.abspath("data/testmovie.mpg"))
|
||||
|
||||
self.timer = wx.Timer(self)
|
||||
self.Bind(wx.EVT_TIMER, self.OnTimer)
|
||||
@@ -74,6 +88,8 @@ class TestPanel(wx.Panel):
|
||||
|
||||
|
||||
def DoLoadFile(self, path):
|
||||
self.playBtn.Disable()
|
||||
noLog = wx.LogNull()
|
||||
if not self.mc.Load(path):
|
||||
wx.MessageBox("Unable to load %s: Unsupported format?" % path,
|
||||
"ERROR",
|
||||
@@ -82,12 +98,18 @@ class TestPanel(wx.Panel):
|
||||
self.mc.SetBestFittingSize()
|
||||
self.GetSizer().Layout()
|
||||
self.slider.SetRange(0, self.mc.Length())
|
||||
self.mc.Play()
|
||||
|
||||
|
||||
def OnMediaLoaded(self, evt):
|
||||
self.playBtn.Enable()
|
||||
|
||||
def OnPlay(self, evt):
|
||||
self.mc.Play()
|
||||
|
||||
if not self.mc.Play():
|
||||
wx.MessageBox("Unable to Play media : Unsupported format?",
|
||||
"ERROR",
|
||||
wx.ICON_ERROR | wx.OK)
|
||||
else:
|
||||
self.slider.SetRange(0, self.mc.Length())
|
||||
|
||||
def OnPause(self, evt):
|
||||
self.mc.Pause()
|
||||
|
||||
@@ -149,4 +171,3 @@ if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||
|
||||
|
Reference in New Issue
Block a user