Josiah:
In the wxPython version 2.6.1.0 i also tried, in the OnFinished function
(bind of wx.EVT_MEDIA_FINISHED) before calling the Load() statement,
Close(), Stop() and Pause().
All results in hanging of the script (application) on the Load statement.
Sometimes a newer release helps one out, so i installed wxPython version
2.6.2.1 the latest version, i think. Guess what it worked. Looking back on
my issue i think it was probably a timing question.
I gave the Play() command before the file was fully Loaded, by Load(), with
the obvious result hanging of the application.
By implementing the new media event wx.EVT_MEDIA_LOADED, fired when the file
is loaded everything works fine.
For anyone who wants to know i added some sample code:
class frmMedia(wx.Frame):
def __init__(self , parent, title):# Add a panel to the frame.
# a playlist
self.list = ['Z:/Mp3/Eminem/The Marshall Mathers LP/03-Stan (feat.
Dido).mp3',
'Z:/Mp3/Eminem/The Marshall Mathers LP/01-Public service
announcement 2000.mp3',
'Z:/Mp3/Eminem/The Marshall Mathers LP/02-Kill you.mp3',
'Z:/Mp3/Eminem/The Marshall Mathers LP/04-Paul (skit).mp3',
'Z:/Mp3/Eminem/The Marshall Mathers LP/14-Amityville (feat.
Bizarre).mp3',
'Z:/Mp3/Eminem/The Marshall Mathers LP/15-Bitch please II
(feat. Dr. Dre, Snoop Dog, Xzibit & Nate Dogg).mp3',
'Z:/Mp3/Eminem/The Marshall Mathers LP/17-Under the influence
(feat. D-12).mp3']
# the playlist index
self.SetIndex(0)
panel = wx.Panel(self)
self.mc = wx.media.MediaCtrl(panel, style=wx.SIMPLE_BORDER)
self.Bind(wx.media.EVT_MEDIA_FINISHED,self.OnFinished,self.mc)
self.Bind(wx.media.EVT_MEDIA_LOADED,self.OnLoaded,self.mc)
self.LoadFile()
def LoadFile(self):
# Loads the file from the playlist called list
self.mc.Load(self.list[self.GetIndex()])
def DoNext(self):
# increment the index of the list, to the next song
self.SetIndex(self.GetIndex()+1)
# load the file
self.LoadFile()
def DoPlay(self):
# Start the playback of the file
self.mc.Play()
def SetIndex(self,pValue):
# Set index of to pValue
self.index=pValue
def GetIndex(self):
# Get the current index
return self.index
def OnLoaded(self, evt):
# Fired when the song (file) is fully loaded
# Only start playing when this event is fired
self.DoPlay()
evt.Skip()
def OnFinished(self, evt):
# When the song ended this event is fired
# Call DoNext to load the next song, playing starts after the
# song (file) is fully loaded, the OnLoaded is fired.
self.DoNext()
evt.Skip()
-----Oorspronkelijk bericht-----
Verzonden: maandag 13 februari 2006 3:36
EVT_MEDIA_FINISHED is trapped in combination with Load
Sorry, I don't have the exact syntax here at home.
There's an event that signals that the media is finished loading in
wx.MediaCtrl. See if it helps to use that event to call Play().
If you re-read the post, you will notice that EVT_MEDIA_FINISHED event
is used to call the Load() and Play() methods of the media control. The
problem is that the program hangs on the Load() call.
Jan:
Have you tried using Stop(), Pause(), Close() ?
- Josiah
···
Van: Josiah Carlson [mailto:jcarlson@uci.edu]
Aan: David Woods; Jan Ripke; wxPython-users@lists.wxwidgets.org
Onderwerp: Re: [wxPython-users] wxMediaCtrl seems to hang when the event
"David Woods" <DWoods@education.wisc.edu> wrote:
>>> jripke@xs4all.nl 02/12/06 4:59 PM >>>
hi,
In order to skip to next song in a playlist i trapped (binded) the
EVT_MEDIA_FINISHED event into the OnFinished function. The OnFinished
function then need to Load the next song and start with playing. To load
the
song i used the function wxMediaCTRL.Load.
When the Load function is called my application hangs, what am i doing
wrong?, can someone help me out?
Below you find the example code to give you information on what i did.
the __init__ part of the class (frmMedia)
try:
self.mc = wx.media.MediaCtrl(panel, -1, style=wx.SIMPLE_BORDER)
self.Bind(wx.media.EVT_MEDIA_FINISHED,self.OnFinished,self.mc)
self.Bind(wx.media.EVT_MEDIA_STOP,self.OnStopped,self.mc)
self.LoadFile()
except NotImplementedError:
self.Destroy()
raise
def OnFinished(self, evt):
# get the next song in the playlist, contains a path
self.SetIndex(self.GetIndex()+1)
# load the next song, application hangs on this point
self.mc.Load('Z:/Mp3/Eminem/The Marshall Mathers LP/02-Kill
you.mp3')
# start playing the next song
self.mc.Play()
evt.Skip()
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org