[Kivy] SoundLoader.load ne charge pas
Bonsoir,
Je voudrai mettre du son dans un petit jeu et j'ai vu qu'il fallait utiliser la librairie SoundLoader.
J'ai bêtement recopié un exemple trouvé sur internet mais ça ne fonctionne pas, j'obtiens ce message d'erreur: Unable to find a loader for <Z:\Projet Jeu\Kivy\Miaou\meow.ogg>
J'ai bien sur essayé un mp3, un wav mais ça ne fonctionne pas non plus.
Précision: Ces sons sont bien lus par VLC
Voici le code, merci de me dire ce qui cloche.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #chat
# coding: utf-8
from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
class ChatApp(App):
def build(self):
Layout=BoxLayout(orientation='vertical',spacing=20,padding=(200,20))
#On cree un bouton:
self.BoutonChat=Button(text='Clique moi!',background_normal="kitty.png")
self.BoutonChat.bind(on_press=self.miaule)
Layout.add_widget(self.BoutonChat)
self.LabelChat=Label(text='Appuie sur le chat', font_size=20)
Layout.add_widget(self.LabelChat)
return Layout
def miaule(self,instance):
#import ipdb; ipdb.set_trace()
sound = SoundLoader.load("meow.ogg")
if sound:
print ( "Sound found at %s " % sound . source )
print ( "Sound is %.3f seconds" % sound . length )
sound.play
else:
print("pas de fichier son en lecture")
if __name__ == '__main__':
ChatApp().run() |