我有一个简单的程序,可以尝试通过播放歌曲的服务制作应用程序。这是我的代码:
main.py
from kivy.app import App
from kivy.lang import Builder
from kivy.utils import platform
kv = '''
Button:
text: 'push me!'
'''
class ServiceApp(App):
def build(self):
if platform == 'android':
from android import AndroidService
service = AndroidService('Song App', 'Song Playing')
service.start('service started')
return Builder.load_string(kv)
ServiceApp().run()
和服务main.py
from kivy.core.audio import SoundLoader
#I have a file called song.wav in the same directory
sound = SoundLoader.load('song.wav')
if sound:
sound.play()
这在Kivy Launcher中非常有效,但是我不知道如何用buildozer打包。任何帮助将不胜感激!