Shillz
Shillz

Reputation: 73

No sound when playing wav file with Kivy and python on MAC

I am using the sound loader module and when running a quick test method to play a sound nothing is being heard.

The file is found as i can pickup the length and location and output it however the sound does not play.

I have tested the WAV file in iTunes and it does work perfectly.

Any help would be appreciated. Code and Log output below:

def playSound():
    sound = SoundLoader.load('hondarev2.wav')
    if sound:
        print("Sound found at %s" % sound.source)
        sound.volume = 1
        sound.loop = True
        sound.play()
        print("Sound is %.3f seconds" % sound.length)

enter image description here

Upvotes: 1

Views: 892

Answers (1)

RufusVS
RufusVS

Reputation: 4127

I am using Kivy with Python 2.7 on a Mac, and this played my sound just fine:

from __future__ import print_function  # I'm using Python 2.7
from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.uix.button import Button

class MyFirstSoundApp(App):
    sound = SoundLoader.load('whistle.wav')  # note, this does not error if file not found!
    def build(self):
        return Button(text="Play!",
            on_press=self.playSound)

    def playSound(self,calledby):
        if self.sound:
            self.sound.play()

if __name__ == "__main__":
    MyFirstSoundApp().run()

Upvotes: 1

Related Questions