kivy制作安卓APP--简单音乐播放器
发布日期:2021-06-29 18:19:20 浏览次数:3 分类:技术文章

本文共 2502 字,大约阅读时间需要 8 分钟。

简述

python kivy库制作的安卓简单音乐播放器,是一个简单小demo,本来用来年会节目控制音乐流程的,分享出来给大家参考,自带kivy launch将该文件解压到根目录,安装里面的launch apk就可以运行。

具体如何使用与安装kivy自行百度。

界面

在这里插入图片描述

源码

# -*-coding:utf-8-*-from kivy.app import Appfrom kivy.uix.screenmanager import ScreenManager, Screenfrom kivy.core.audio import SoundLoader,Soundfrom kivy.lang import BuilderBuilder.load_string('''
: BoxLayout: orientation:'vertical' Button: text:'Yi_Jian_Mei' on_press:root.plays() Button: text:'Shi_Nian' on_press:root.plays2() Button: text:'Shi_Nian_Gao_Chao' on_press:root.plays3() Button: text:'Shi_Nian_Xu_Jie' on_press:root.plays4() Button: text:'Shao_Nian' on_press:root.plays5()''')class MenuPage(Screen): M = SoundLoader.load('1.mp3') #一剪梅 M2 = SoundLoader.load('2.mp3') #十年 M3 = SoundLoader.load('3.mp3') #演员唱十年 M4 = SoundLoader.load('4.mp3') #唱错词后接着的十年 M5 = SoundLoader.load('5.mp3') #少年 def plays(self): if MenuPage.M.state == 'stop': MenuPage.M4.stop() MenuPage.M2.stop() MenuPage.M5.stop() MenuPage.M3.stop() MenuPage.M.play() else: MenuPage.M.stop() def plays2(self): if MenuPage.M2.state == 'stop': MenuPage.M.stop() MenuPage.M4.stop() MenuPage.M3.stop() MenuPage.M5.stop() MenuPage.M2.play() else: MenuPage.M2.stop() def plays3(self): if MenuPage.M3.state == 'stop': MenuPage.M.stop() MenuPage.M4.stop() MenuPage.M2.stop() MenuPage.M5.stop() MenuPage.M3.play() else: MenuPage.M3.stop() def plays4(self): if MenuPage.M4.state == 'stop': MenuPage.M.stop() MenuPage.M3.stop() MenuPage.M2.stop() MenuPage.M5.stop() MenuPage.M4.play() else: MenuPage.M4.stop() def plays5(self): if MenuPage.M5.state == 'stop': MenuPage.M.stop() MenuPage.M3.stop() MenuPage.M4.stop() MenuPage.M2.stop() MenuPage.M5.play() else: MenuPage.M5.stop()sm = ScreenManager()menu = MenuPage(name='menu')sm.add_widget(menu)class TestApp(App): def build(self): return smif __name__ in ('__main__', '__android__'): TestApp().run()

转载地址:https://cxk-life.blog.csdn.net/article/details/111322135 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:十年(程序员改编)
下一篇:caffe模型简单调用

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月10日 16时28分48秒