Playing sound on windows

282 views
Skip to first unread message

i...@pcli.mygbiz.com

unread,
Sep 22, 2015, 6:04:29 AM9/22/15
to Kivy users support
I'm trying to play a sound on my windows 10 machine and I keep getting errors with every file type I try to play. When I build it for android it plays just fine. When I try mp3 or ogg I get an error like this:
[INFO              ] [Audio       ] Providers: audio_sdl2 (audio_ffpyplayer ignored)
[INFO              ] [Text        ] Provider: sdl2
[WARNING           ] [Audio       ] Unable to find a loader for <sound/POP.ogg>

And if I try to run a wav I get this:
File "kivy\core\audio\audio_sdl2.pyx", line 152, in kivy.core.audio.audio_sdl2.SoundSDL2.load (kivy\core/audio\audio_sdl2.c:2867)
 TypeError: expected bytes, str found

What's going on? I've never had any issues with sound on windows before.

Karla Muguerza

unread,
Sep 23, 2015, 10:49:16 AM9/23/15
to Kivy users support
Hi, have you tried with wav?

i...@pcli.mygbiz.com

unread,
Sep 23, 2015, 4:31:41 PM9/23/15
to Kivy users support
Yes, and I get the last error shown above when I try that.

ZenCODE

unread,
Sep 24, 2015, 2:37:45 AM9/24/15
to Kivy users support
Are you using the 2.7 or 3 version? And how exactly do you specify the path of the audio file?

Karla Muguerza

unread,
Sep 24, 2015, 11:51:50 AM9/24/15
to Kivy users support
I share with you a running example, I noticed that I've got other sound providers. I ran this with a mp3 and wav examples. 

import kivy
kivy.require('1.9.0')

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.core.audio import SoundLoader


class MyW(Widget):
sound = SoundLoader.load('blip.mp3')
sound.play()

class Shape(App):
def build(self):
return MyW()

if __name__=='__main__':
Shape().run()


And 

[INFO              ] [AudioGstplayer] Using Gstreamer 1.4.5.0
[INFO              ] [Audio       ] Providers: audio_gstplayer, audio_sdl2 (audio_ffpyplayer ignored)

i...@pcli.mygbiz.com

unread,
Sep 24, 2015, 12:39:52 PM9/24/15
to Kivy users support
Thanks for the code example. I'm using the same approach as you and as I said the same code works fine when I run it on android. This seems to be more of a set-up issue.

ZenCode - I'm using python the package for python 3 from Christophe Gohlke. Would that make a difference? Should I be using Python 2.7? I don't really want to go backwards with that. Just as a note, I also tried the kivy portable package for python 3 because that seems to have everything set up for gstreamer and such but the kivy.bat file kept erroring out saying there was no such module as kivy. Since sound works on my android builds I know my code is good but it makes it really hard to debug sound if I can't test on my dev box.  

i...@pcli.mygbiz.com

unread,
Sep 28, 2015, 11:26:59 AM9/28/15
to Kivy users support
Any ideas what could be going wrong?

ZenCODE

unread,
Sep 28, 2015, 1:57:07 PM9/28/15
to Kivy users support
Difficult for me to say. I just know bytes vs. string is common 2 vs. 3 issue. Also, support for Python 3 in Python 4 android is still experimental. Personally, I would try 2: you can write code that works for both. Full Python 3 support will come, but using 2 for now might save you headaches...

But yeah, sorry, can't help you much more that that....;-)

i...@pcli.mygbiz.com

unread,
Oct 11, 2015, 8:19:11 PM10/11/15
to Kivy users support
I tried Python 2 and got the exact same issue. Do I need to manually install g-streamer? If so I'm at a loss on how to do that because I haven't found any docs explaining how to get g-streamer working with python under windows.

ZenCODE

unread,
Oct 12, 2015, 2:47:44 AM10/12/15
to Kivy users support
GStreamer is bunldled with Kivy, so you don't need to install it. But on Windows, you cannot play 'mp3' files by default. There are legal codec issues around that (I think). 'wav' or 'ogg' files are best for testing. If those don't work, please post you full error trace. There are also ways for you can force different audio providers, but lets leave that as a last resort...

Cheers

i...@pcli.mygbiz.com

unread,
Oct 12, 2015, 11:01:52 AM10/12/15
to Kivy users support
  With my install of kivy I don't see any mention of gstreamer in the logs. Do you mean that gstreamer comes bundled with the portable version of kivy? If so I can't get that version to even load the kivy demos. Something's wrong with it. It says that kivy can't even be imported in its logs. That's actually a separate issue but it needs looked into. I've used the portable version since kivy 1.7 and never had an issue until the most recent version. Something's broken on this one. 
  Anyway back to my main problem. I've tried .wav and .ogg and I'm certain that there has never been a problem with .mp3 on windows (I've done a lot of sound engineering with it for years on windows) but all of them come up with errors - .wav is the one that has the bytes vs string error. I get these errors with every version of python (2.7 - 3.5, 32bit or 64bit). Here is a print out:

i...@pcli.mygbiz.com

unread,
Oct 12, 2015, 2:20:00 PM10/12/15
to Kivy users support
I don't know what problem I was having with the portable version before (Python 3 version?) but I tried the Python27 version and sound works just fine through that. I'll just use this through eclipse. Thanks for your help!
Reply all
Reply to author
Forward
0 new messages