![]() |
2010-04-24
, 10:04
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#2
|
![]() |
2010-04-24
, 13:06
|
|
Posts: 1,366 |
Thanked: 1,185 times |
Joined on Jan 2006
|
#3
|
![]() |
2010-04-24
, 17:58
|
|
Posts: 487 |
Thanked: 152 times |
Joined on Aug 2007
@ London, UK
|
#4
|
I'm no Python buff, but white space is very important. In your pauseSong method, you've got an extra space on the second if-statement line.
This will give the parser trouble.
![]() |
2010-04-24
, 18:20
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#5
|
![]() |
2010-04-24
, 18:27
|
|
Posts: 334 |
Thanked: 171 times |
Joined on Dec 2009
|
#6
|
![]() |
2010-04-24
, 18:30
|
|
Posts: 1,635 |
Thanked: 1,816 times |
Joined on Apr 2008
@ Manchester, England
|
#7
|
![]() |
2010-04-24
, 22:48
|
|
Posts: 3,203 |
Thanked: 1,391 times |
Joined on Nov 2009
@ Worthing, England
|
#8
|
doesnt the python mixer have get_busy() method which can be used to check if things are in use?
pseudocode:
if pygame.mixer.get_busy()
python.mixer.pause()
else
python.mixer.unpause()
certainly sounds more feasible to me, but there might be a reason you cannot use similar
you shouldn't need to retain the state - technically it should come from each channel/the mixer
![]() |
2010-04-24
, 23:43
|
Posts: 47 |
Thanked: 22 times |
Joined on Apr 2010
|
#9
|
That's just a false-positive, an error that slipped when I copy-pasted, so that's not the problem I'm afraid
just added that but it doesn't seem to change much.
ANyways, thanks for the input guys!
#initial conditions playing = False paused = True ... #This is where it doesn't work def pauseSong(): print "TEST" #This gets printed if playing == True: pygame.mixer.pause() #This *should* pause the song print "paused" # This doesn't get printed :( paused = True if playing == False: pygame.mixer.unpause() pause = False ...
#Starts the playback of the song def startSong(): print "Song Stared" playing = True # This changes the initial conditions paused = False print playing song.play() time.sleep(.1)
![]() |
2010-04-24
, 23:44
|
Posts: 324 |
Thanked: 371 times |
Joined on Dec 2009
@ Vancouver, BC
|
#10
|
The Following 2 Users Say Thank You to Slocan For This Useful Post: | ||
I've been stuck on the following for quite some time now so any help is GREATLY appreciated
I'm trying to create a Play/Pause button: Ive already got the play part sorted but I cant seem to get the looping part right!
My program will play the song when the "Play" button is played. Im trying to set up a loop that detect if the song is playing and it it is, it will pause it, if not, it will resume it.
Here's the code:
As you can see, im quite stuck.
Does anyone have an idea? Should I consider nested loops?
Or maybe assign 2 Slots for 1 signal?
Follow me on twitter HERE!
Applications I've made:
- Vuvuzela
- LTM: London Tube Map
Last edited by El Amir; 2010-04-24 at 18:01.