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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月10日 16时28分48秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
spark期末大作业
2019-04-30
NC自定义日志输出
2019-04-30
NC按钮增加风车加载页面
2019-04-30
NC 点击图片放大
2019-04-30
JAVA 文件类型识别
2019-04-30
NC6 业务参数操作
2019-04-30
NC 一次更新1000条以上数据
2019-04-30
NC 在后台使用System.out打印
2019-04-30
NC ws接口防XXE注入
2019-04-30
NC sql信息打印控制台
2019-04-30
NC6 弹窗显示网页
2019-04-30
NC6 对组件进行AOP编程
2019-04-30
wx:for循环相关页面布局
2019-04-30
多个picker组件的使用
2019-04-30
折叠面板的实现(点击展开全部内容)
2019-04-30
Bootstrap弹出框(popover)中插入图片
2019-04-30
Bootstrap默认的弹出框(popover)
2019-04-30
v-for 实现模块的增加、删除以及v-for条件下的input双向绑定
2019-04-30
v-for条件下的input双向绑定
2019-04-30
腾讯T2大牛亲自讲解!mysql更新数据语句
2019-04-30