InDashPC.org Forum Index InDashPC.org
In Dash Car PC forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pymedia asynchrony

 
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software -> PyMedia Tutorials
View previous topic :: View next topic  
Author Message
Gamur
Newbie


Joined: 12 Jul 2006
Posts: 7

PostPosted: Wed Jul 12, 2006 9:18 am    Post subject: Pymedia asynchrony Reply with quote

Hello, I am new to Pymedia and am looking for an answer about playing and then stopping sound before the entire wav file is played. In the tutorial about playing a wav file, it says to add the line involving time.sleep if you want to play the entire sound before returning. But it seems that even without this line, it is playing the entire sound before returning. I am building a user interface where a user can start playing a sound, and then if they are not interested in hearing the whole thing they can stop it. How can that be done with pymedia? Anything I code in after snd.play(s) is ignored until the wav file is done playing.
Thanks,
Gabriel
Back to top
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Wed Jul 12, 2006 11:33 am    Post subject: Reply with quote

Can you take a look at the player.py example ?
It reacts on button presses and does seek, next/prev and so on.
Back to top
View user's profile Send private message
Gamur
Newbie


Joined: 12 Jul 2006
Posts: 7

PostPosted: Wed Jul 12, 2006 3:02 pm    Post subject: setStartTime Reply with quote

Great, thanks for the tip.
In the following script, I'm able to do setEndTime no problem, but when I do setStartTime it exits with the error:

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/pymedia/player.py", line 758, in _readerLoop
self.snd.stop()
AttributeError: 'NoneType' object has no attribute 'stop'


Do you know why this is?

Here is the code:

###########
player = pymedia.Player()

player.setStartTime(1.0)
player.setEndTime(2.0)
player.start()

player.startPlayback('samp.wav')
while player.isPlaying():
time.sleep(0.5)
Back to top
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Wed Jul 12, 2006 9:10 pm    Post subject: Reply with quote

Try to get the latest CVS version. I just fixed it.
Back to top
View user's profile Send private message
Gamur
Newbie


Joined: 12 Jul 2006
Posts: 7

PostPosted: Thu Jul 13, 2006 2:51 am    Post subject: setStartTime Reply with quote

That's great, thanks. I no longer get that error. However, it doesn't seem like it responds to me setting the start time with player.setStartTime(). Regardless of what I set this value to, it begins at the beginning of the wav value. Are both setStartTime() and setEndTime() meant to be in seconds?
Thanks,
Back to top
View user's profile Send private message
Gamur
Newbie


Joined: 12 Jul 2006
Posts: 7

PostPosted: Fri Jul 14, 2006 5:24 am    Post subject: setStartTime() Reply with quote

Does anybody else find that setting the start time with player.setStartTime() makes no difference? For me it still starts at the beginning of the wav file.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software -> PyMedia Tutorials All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group