python - Android: Playing a sound from Kivy background service -


i trying create simple alarm clock in kivy android.

i've got communication between background app , user interface (ui): background app sending data ui @ specified hour.

but can't generate sound or vibration service. works ui, not service.

i did try sound.play() kivy.core.audio. logcat:

attributeerror: 'nonetype' object has no attribute 'play' 

the same if use jnius vibrate:

attributeerror: 'nonetype' object has no attribute 'getsystemservice' 

i did try vibrations pyjnius this way , sound sound, which, said works on ui, this:

from kivy.core.audio import soundloader sound = soundloader.load('sound.wav') 

and then:

sound.play() 

update:

after lafadas' update sound still not play, function continues after error , not break instantly.

in logcat see this, if relevant:

kivy service log:     [info              ] logger: record log in /storage/emulated/0/org.alkowatch/service/.kivy/logs/kivy_14-12-02_3.txt [    info              ] kivy v1.8.0     [info              ] osc: using <thread> socket     [info              ] audio: providers:  (audio_pygst, audio_sdl, audio_pygame ignored)     [warning           ] audio: unable find loader <sound.wav>     [debug             ] osc: start thread <0.0.0.0:3000>     [info              ] osc: listening tuio on 0.0.0.0:3000 

you have check if sound none. if is, file didn't load.

from documentation load():

set true if sound should automatically loop when finishes.

loop booleanproperty , defaults false.

so please check value:

from kivy.core.audio import soundloader  sound = soundloader.load('sound.wav') if sound:     print("sound found @ %s" % sound.source)     print("sound %.3f seconds" % sound.length)     sound.play() 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -