Some tweaks for the wxMediaCtrl and enhaced the demo a bit
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30904 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3,6 +3,8 @@ import wx
|
|||||||
import wx.media
|
import wx.media
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from Main import opj
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
class TestPanel(wx.Panel):
|
class TestPanel(wx.Panel):
|
||||||
@@ -12,23 +14,27 @@ class TestPanel(wx.Panel):
|
|||||||
style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN)
|
style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN)
|
||||||
|
|
||||||
# Create some controls
|
# Create some controls
|
||||||
self.mc = wx.media.MediaCtrl(self)
|
self.mc = wx.media.MediaCtrl(self, -1, opj("data/testmovie.mpg"),
|
||||||
self.mc.SetMinSize((320,200))
|
style=wx.SIMPLE_BORDER)
|
||||||
|
self.mc.SetBackgroundColour("black")
|
||||||
|
#self.mc.SetMinSize((320,200))
|
||||||
|
self.mc.Stop()
|
||||||
|
|
||||||
btn1 = wx.Button(self, -1, "Load File")
|
btn1 = wx.Button(self, -1, "Load File")
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn1)
|
self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn1)
|
||||||
|
|
||||||
btn2 = wx.Button(self, -1, "Load URL")
|
btn2 = wx.Button(self, -1, "Play")
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnLoadURI, btn2)
|
self.Bind(wx.EVT_BUTTON, self.OnPlay, btn2)
|
||||||
|
|
||||||
btn3 = wx.Button(self, -1, "Play")
|
btn3 = wx.Button(self, -1, "Pause")
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnPlay, btn3)
|
self.Bind(wx.EVT_BUTTON, self.OnPause, btn3)
|
||||||
|
|
||||||
btn4 = wx.Button(self, -1, "Pause")
|
btn4 = wx.Button(self, -1, "Stop")
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnPause, btn4)
|
self.Bind(wx.EVT_BUTTON, self.OnStop, btn4)
|
||||||
|
|
||||||
|
btn5 = wx.ToggleButton(self, -1, "Loop")
|
||||||
|
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnLoopToggle, btn5)
|
||||||
|
|
||||||
btn5 = wx.Button(self, -1, "Stop")
|
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnStop, btn5)
|
|
||||||
|
|
||||||
# setup the layout
|
# setup the layout
|
||||||
sizer = wx.GridBagSizer(5,5)
|
sizer = wx.GridBagSizer(5,5)
|
||||||
@@ -48,8 +54,8 @@ class TestPanel(wx.Panel):
|
|||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
path = dlg.GetPath()
|
path = dlg.GetPath()
|
||||||
if not self.mc.Load(path):
|
if not self.mc.Load(path):
|
||||||
wx.MessageBox("Unable to load %s." % path,
|
wx.MessageBox("Unable to load %s: Unsupported format?" % path,
|
||||||
"ERROR: Unsupported format?",
|
"ERROR",
|
||||||
wx.ICON_ERROR | wx.OK)
|
wx.ICON_ERROR | wx.OK)
|
||||||
else:
|
else:
|
||||||
self.mc.SetBestFittingSize()
|
self.mc.SetBestFittingSize()
|
||||||
@@ -57,18 +63,9 @@ class TestPanel(wx.Panel):
|
|||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
|
|
||||||
def OnLoadURI(self, evt):
|
def OnLoopToggle(self, evt):
|
||||||
dlg = wx.TextEntryDialog(self, "URL:", "Please enter the URL of a media file",
|
btn = evt.GetEventObject()
|
||||||
"http://www.mwscomp.com/movies/grail/tim-the-enchanter.avi")
|
self.mc.Loop(btn.GetValue())
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
|
||||||
url = dlg.GetValue()
|
|
||||||
if not self.mc.LoadFromURI(url):
|
|
||||||
wx.MessageBox("Unable to load %s." % url,
|
|
||||||
"ERROR", wx.ICON_ERROR | wx.OK)
|
|
||||||
else:
|
|
||||||
self.mc.SetBestFittingSize()
|
|
||||||
self.GetSizer().Layout()
|
|
||||||
dlg.Destroy()
|
|
||||||
|
|
||||||
|
|
||||||
def OnPlay(self, evt):
|
def OnPlay(self, evt):
|
||||||
|
@@ -179,7 +179,8 @@ public:
|
|||||||
%pythonAppend wxMediaCtrl() ""
|
%pythonAppend wxMediaCtrl() ""
|
||||||
|
|
||||||
|
|
||||||
wxMediaCtrl(wxWindow* parent, wxWindowID id=-1,
|
wxMediaCtrl(wxWindow* parent,
|
||||||
|
wxWindowID id=-1,
|
||||||
const wxString& fileName = wxPyEmptyString,
|
const wxString& fileName = wxPyEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
@@ -192,7 +193,8 @@ public:
|
|||||||
|
|
||||||
%extend {
|
%extend {
|
||||||
%name(MediaCtrlFromURI)
|
%name(MediaCtrlFromURI)
|
||||||
wxMediaCtrl(wxWindow* parent, wxWindowID id=-1,
|
wxMediaCtrl(wxWindow* parent,
|
||||||
|
wxWindowID id=-1,
|
||||||
const wxString& location=wxPyEmptyString,
|
const wxString& location=wxPyEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
@@ -205,7 +207,8 @@ public:
|
|||||||
pos, size, style, szBackend, validator, name);
|
pos, size, style, szBackend, validator, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateFromURI(wxWindow* parent, wxWindowID id=-1,
|
bool CreateFromURI(wxWindow* parent,
|
||||||
|
wxWindowID id=-1,
|
||||||
const wxString& location=wxPyEmptyString,
|
const wxString& location=wxPyEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
@@ -220,7 +223,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Create(wxWindow* parent, wxWindowID id=-1,
|
bool Create(wxWindow* parent,
|
||||||
|
wxWindowID id=-1,
|
||||||
const wxString& fileName = wxPyEmptyString,
|
const wxString& fileName = wxPyEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
@@ -249,9 +253,9 @@ public:
|
|||||||
double GetPlaybackRate();
|
double GetPlaybackRate();
|
||||||
bool SetPlaybackRate(double dRate);
|
bool SetPlaybackRate(double dRate);
|
||||||
|
|
||||||
bool SetPosition(wxLongLong where);
|
%name(SetMediaPosition) bool SetPosition(wxLongLong where);
|
||||||
wxLongLong GetPosition();
|
%name(GetMediaPosition) wxLongLong GetPosition();
|
||||||
wxLongLong GetDuration();
|
%name(GetMediaDuration) wxLongLong GetDuration();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user