我在Fedora 20上为python 2.7安装了kivy版本1.8.1
因为我是kivy的新手我想知道我是否可以在Android和IOS中使用kivy进行音频流
我尝试了一个例子,但它甚至没有在我的桌面上播放
from kivy.app import App
from kivy.core.audio import SoundLoader
class TestApp(App):
def build(self):
sound = SoundLoader.load('http://194.106.198.57:8090/club_low.mp3')
if sound:
print("Sound found at %s" % sound.source)
print("Sound is %.3f seconds" % sound.length)
sound.play()
TestApp().run()
上述代码的输出:
[INFO ] Kivy v1.8.0
[INFO ] [Logger ] Record log in /home/mohammad/.kivy/logs/kivy_14-09-11_13.txt
[INFO ] [Factory ] 157 symbols loaded
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60s
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=Nones
[INFO ] [Image ] Providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600s
[DEBUG ] [Audio ] register SoundPygame
[INFO ] [Audio ] Providers: audio_pygame (audio_pygst, audio_sdl ignored)
[DEBUG ] [App ] Loading kv </home/work/python/pama_radio/andriod_app/test.kv>
[DEBUG ] [App ] kv </home/work/python/pama_radio/andriod_app/test.kv> not found
[WARNING ] [Audio ] Unable to find a loader for <http://194.106.198.57:8090/club_low.mp3>
Traceback (most recent call last):
File "/home/work/python/pama_radio/andriod_app/main.py", line 11, in <module>
TestApp().run()
File "/usr/lib/python2.7/site-packages/kivy/app.py", line 766, in run
root = self.build()
File "/home/work/python/pama_radio/andriod_app/main.py", line 9, in build
print("Sound is %.3f seconds" % sound.length)
AttributeError: 'NoneType' object has no attribute 'length'
Process finished with exit code 1
我试过视频和视频播放器模块,它只适用于DESKTOPS中的流媒体,它不适用于android(我没试过IOS) 如果我可以使用其他格式(如aac和ogg)
,请告诉我答案 0 :(得分:1)
这种情况正在发生,因为在桌面上你正在使用gstplayer--基于GStreamer的音频提供商 - 而Android则使用pygame作为其音频提供商。虽然GStreamer支持通过网络传输音频,但pygame却不支持。
如果您查看在桌面上运行应用程序的输出,您应该看到以下内容:
[INFO ] [Audio ] Providers: audio_gstplayer, audio_pygame (audio_ffpyplayer, audio_sdl ignored)
这意味着Kivy正在使用gstplayer和pygame - 如果gstplayer无法处理给定的媒体类型,那么Kivy将尝试使用pygame。但是Android上没有gstplayer:
[INFO ] [Audio ] Providers: audio_pygame (audio_pygst, audio_sdl ignored)
在iOS上,使用了SDL音频提供程序,我相信它可能支持流式传输,所以你可能会有更好的运气。您还可以submit an issue on github请求我们添加此功能。