SoundLoader issue

341 views
Skip to first unread message

Auggie

unread,
Oct 31, 2017, 6:32:52 PM10/31/17
to Kivy users support

Why can't I load sounds with Kivy, when I'm following the instructions on the Kivy website precisely? Any help is greatly appreciated! 

The following example is from https://kivy.org/docs/api-kivy.core.audio.html:

from kivy.core.audio import SoundLoader

sound = SoundLoader.load('mytest.wav')
if sound:
    print("Sound found at %s" % sound.source)
    print("Sound is %.3f seconds" % sound.length)
    sound.play()

I've copied and pasted this example into a blank Python file, and ran the code. I've made sure to use a valid wav file for 'mytest.wav', and have placed the wav file in the same directory as the Python file. 

I get the following error message:

/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/MyUsername/PycharmProjects/MyProject/sound_test.py
[INFO   ] [Logger      ] Record log in /Users/MyUsername/.kivy/logs/kivy_17-10-24_4.txt
[INFO   ] [Kivy        ] v1.10.1.dev0, git-Unknown, 20170911
[INFO   ] [Python      ] v3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
[INFO   ] [AudioGstplayer] Using Gstreamer 1.12.2.0
[INFO   ] [Audio       ] Providers: audio_gstplayer, audio_sdl2 (audio_ffpyplayer, audio_avplayer ignored)
 Traceback (most recent call last):
   File "/Users/MyUsername/PycharmProjects/MyProject/sound_test.py", line 3, in <module>
     sound = SoundLoader.load("mytest.wav")
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/kivy/core/audio/__init__.py", line 86, in load
     return classobj(source=filename)
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/kivy/core/audio/audio_gstplayer.py", line 45, in __init__
     super(SoundGstplayer, self).__init__(**kwargs)
   File "kivy/_event.pyx", line 262, in kivy._event.EventDispatcher.__init__
   File "kivy/properties.pyx", line 478, in kivy.properties.Property.__set__
   File "kivy/properties.pyx", line 516, in kivy.properties.Property.set
   File "kivy/properties.pyx", line 571, in kivy.properties.Property.dispatch
   File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy/_event.pyx", line 1120, in kivy._event.EventObservers._dispatch
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/kivy/core/audio/__init__.py", line 174, in on_source
     self.load()
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/kivy/core/audio/audio_gstplayer.py", line 62, in load
     self.player.load()
   File "kivy/lib/gstplayer/_gstplayer.pyx", line 233, in kivy.lib.gstplayer._gstplayer.GstPlayer.load
 kivy.lib.gstplayer._gstplayer.GstPlayerException: Unable to create a playbin

Process finished with exit code 1

CorwinSTP

unread,
Nov 2, 2017, 3:47:04 AM11/2/17
to Kivy users support
Does it still happen if you use sdl2 for kivy audio?

from os import environ
environ['KIVY_AUDIO'] = 'sdl2'

Arie Schachter

unread,
Nov 2, 2017, 1:11:48 PM11/2/17
to kivy-...@googlegroups.com
Thank you for your reply, Corwin! Unfortunately the two lines of code you suggested did not affect the error message. Please let me know if you have any other ideas. Thanks! 

Sent from my iPhone
--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/jVajCPtePHM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Walker

unread,
Nov 2, 2017, 1:16:58 PM11/2/17
to Kivy users support
GST Player has always been an issue on Macs.  I have run into this problem many times before.  And if you are using the default Kivy, it will not let you go to SDL dynamically.  My solution has always been to recompile Kivy from source with Gstreamer removed, forcing it to link with SDL.

I do this every semester for my students with Macs.

Auggie

unread,
Nov 2, 2017, 1:43:48 PM11/2/17
to Kivy users support
Thank you for your reply, Walker! I'm relatively a beginner, and not sure how to recompile kivy. If you have a minute to share what commands I should type in the terminal, that would help me so much! I totally understand if that's too time-consuming. Thanks! 

Walker

unread,
Nov 2, 2017, 2:16:17 PM11/2/17
to Kivy users support


On Thursday, November 2, 2017 at 1:43:48 PM UTC-4, Auggie wrote:
Thank you for your reply, Walker! I'm relatively a beginner, and not sure how to recompile kivy. If you have a minute to share what commands I should type in the terminal, that would help me so much! I totally understand if that's too time-consuming. Thanks! 

You need Cython and XCode installed.

Download SDL2 Development: SDL2-2.0.7.dmg

Put that in /Library/Frameworks (the installer should do that automatically)

Also download the SDL2 support libraries:


Those also go in /Libary/Frameworks 

Download the latest Kivy from GitHub: https://github.com/kivy/kivy

Unzip the folder. Go into the folder with Terminal and type make

Some warning will be generated, but you will be okay.  The key thing is the start should look like this:

Build configuration is:

 * use_rpi = 0

 * use_mali = 0

 * use_egl = 0

 * use_opengl_es2 = 1

 * use_opengl_mock = 0

 * use_sdl2 = 1

 * use_ios = 0

 * use_mesagl = 0

 * use_x11 = 0

 * use_gstreamer = 0

 * use_avfoundation = 1

 * use_osx_frameworks = 1

 * debug_gl = 0

 * debug = False


Then type make install



Auggie

unread,
Nov 2, 2017, 9:26:21 PM11/2/17
to Kivy users support
Thanks, Walker! The installation attempts from all the .dmg links in your message result in "cannot execute binary file

logout". It's possible that my computer is too old... I'll try these steps again when I buy a new computer. Thanks again! 

Reply all
Reply to author
Forward
0 new messages