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 

stopping play mp3

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



Joined: 03 Apr 2007
Posts: 4

PostPosted: Mon Apr 16, 2007 6:23 am    Post subject: stopping play mp3 Reply with quote

how can i stop the play mp3 ?
Because if use this code i don't do nothing if file mp3 is playing ? Rolling Eyes


Code:

import pymedia
import time

demuxer = pymedia.muxer.Demuxer('mp3')

f = open(YOUR FILE HERE, 'rb')


spot = f.read()
frames = demuxer.parse(spot)
print 'read it has %i frames' % len(frames)
decoder = pymedia.audio.acodec.Decoder(demuxer.streams[0])
frame = decoder.decode(spot)
print dir(frame)
sound = pymedia.audio.sound
print frame.bitrate, frame.sample_rate
song = sound.Output( frame.sample_rate, frame.channels, 16 )

while len(spot) > 0:
    try:
        if frame: song.play(frame.data)
        spot = f.read(512)
        frame = decoder.decode(spot)
    except:
        pass
   
while song.isPlaying(): time.sleep(.05)
print 'well done'

Back to top
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Tue Apr 17, 2007 4:31 pm    Post subject: Reply with quote

Basically once you stop feeding the data to codec or sound card it will stop playing.
Take a look at the Player object in pymedia. It has pause() method.
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