PDA

View Full Version : Play a sound


Nuka1195
2005-06-12, 01:35
is there anyway to play a .wav file with python. one of the navigation sounds.

what i want to do is, if music is playing pause the playback, play a sound (wav file) and then start the music playback again.

the only way i can think of is to let the script control a playlist. stop the playlist, play an mp3, then restart the playlist, i guess from the begining.

thanks

Nuka1195
2005-06-15, 05:15
in case anybody wanted to know. you can use xbmc.player().play(file) and when that file is done playing, your playlist or the folder your playing continues. :)

but i have a weird problem, when activating the visualisation window. i have to call a xbmc.player() command (playnext(), playprevious(), play(), pause()) or else my only visible control on the dialog loses focus and a setfocus will not work. play() messes up the playlist since i play an alert.mp3, i don't want to skip the currently playing song, so i use two pause()'s.

should the setfocus work or is there a better way than how i'm doing it?

thanks.

def starttimer(self):
* *if xbmc.player().isplayingaudio():
* * * *if self.music_playing:
* * * * * *xbmc.executebuiltin('xbmc.activatewindow(2006)')
* * * *if self.music_playing and xbmc.player().getplayingfile() == alarmfile:
* * * * * *xbmc.player().playnext()
* * * *elif xbmc.player().getplayingfile() == alarmfile:
* * * * * *xbmc.player().stop()
* * * *else:
* * * * * *xbmc.player().pause()
* * * * * *xbmc.player().pause()

Nuka1195
2005-06-16, 04:53
in case for future reference a simple sleep(.05) before the setfocus() did the trick.

else:
sleep(.05)