Kodi Community Forum

Full Version: Play a sound
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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. Smile

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.

Quote: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()
in case for future reference a simple sleep(.05) before the setfocus() did the trick.

Quote:else:
sleep(.05)