Python kivy sounds不';我不想在Win8上工作
我已经在ubuntu上测试了我的代码,它工作正常,但是当我在windows8上测试时,声音没有播放出来 我编写了一个新的应用程序,但它也不起作用。windows有特殊设置吗? 为什么我不能播放声音 这将是一个移动应用程序,但尚未完成。 问题出在哪里? 它在手机上工作吗 这是我的密码:Python kivy sounds不';我不想在Win8上工作,python,linux,windows,kivy,Python,Linux,Windows,Kivy,我已经在ubuntu上测试了我的代码,它工作正常,但是当我在windows8上测试时,声音没有播放出来 我编写了一个新的应用程序,但它也不起作用。windows有特殊设置吗? 为什么我不能播放声音 这将是一个移动应用程序,但尚未完成。 问题出在哪里? 它在手机上工作吗 这是我的密码: from kivy.uix.screenmanager import ScreenManager, Screen from kivy.lang import Builder from kivy.app import
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.popup import Popup
#from kivy.uix.label import Label
from kivy.core.audio import SoundLoader
Builder.load_string('''
<MenuPage>:
BoxLayout:
BoxLayout:
size_hint:(.1, None)
Button:
text: 'Credit'
on_press:root.show_popup()
ListView:
size_hint: .8, .97
item_strings: [str(index) for index in range(40)]
BoxLayout:
size_hint:(.1, None)
Button:
text: 'atlas'
on_press:root.plays()
<Page>:
BoxLayout:
BoxLayout:
size_hint:(.1, None)
Button:
text: 'MENU'
on_press: root.manager.current = 'menu'
BoxLayout:
orientation:'vertical'
Button:
text:root.name
size_hint:(1, .2)
Image:
source: '/home/hosein/Pictures/1.png'
size_hint:(1, .8)
BoxLayout:
size_hint:(.1, None)
Button:
text: 'atlas'
<Credit>:
auto_dismiss: False
title: 'CREDIT'
size_hint:.6, .6
BoxLayout:
orientation:'vertical'
Label:
text:'Coded By hosein Ramezan'
Button:
text: 'close'
size_hint:1, .2
on_press: root.dismiss()
''')
class Credit(Popup):
pass
class MenuPage(Screen):
M = SoundLoader.load('/home/hosein/Music/Man.mp3')
M.play()
def plays(self):
if MenuPage.M.state == 'stop':
MenuPage.M.play()
else:
MenuPage.M.stop()
def show_popup(self):
P = Credit()
P.open()
class Page(Screen):
pass
sm = ScreenManager()
menu = MenuPage(name='menu')
sm.add_widget(menu)
for i in range(4):
name = Page(name=str(i))
sm.add_widget(name)
class TestApp(App):
def build(self):
return sm
if __name__ == '__main__':
TestApp().run()
从kivy.uix.screenmanager导入screenmanager,屏幕
从kivy.lang导入生成器
从kivy.app导入应用程序
从kivy.uix.popup导入弹出窗口
#从kivy.uix.label导入标签
从kivy.core.audio导入SoundLoader
Builder.load_字符串(“”)
:
盒子布局:
盒子布局:
大小提示:(.1,无)
按钮:
文字:“信用”
按:root.show\u popup()
列表视图:
大小提示:.8,.97
item_字符串:[范围(40)内索引的str(索引)]
盒子布局:
大小提示:(.1,无)
按钮:
文本:“atlas”
按:root.plays()
:
盒子布局:
盒子布局:
大小提示:(.1,无)
按钮:
文本:“菜单”
按:root.manager.current='菜单'
盒子布局:
方向:'垂直'
按钮:
text:root.name
大小提示:(1,.2)
图片:
来源:“/home/hosein/Pictures/1.png”
尺寸提示:(1.8)
盒子布局:
大小提示:(.1,无)
按钮:
文本:“atlas”
:
自动解除:错误
标题:“信用”
大小提示:.6,.6
盒子布局:
方向:'垂直'
标签:
文本:“由hosein Ramezan编码”
按钮:
文本:“关闭”
尺寸提示:1.2
按:root.discouse()
''')
课程学分(弹出窗口):
通过
类菜单页(屏幕):
M=SoundLoader.load('/home/hosein/Music/Man.mp3')
M.play()
def播放(自我):
如果MenuPage.M.state==“停止”:
MenuPage.M.play()
其他:
MenuPage.M.停止()
def显示_弹出窗口(自身):
P=信用()
P.公开
课堂页面(屏幕):
通过
sm=屏幕管理器()
menu=MenuPage(name='menu')
sm.add_小部件(菜单)
对于范围(4)中的i:
姓名=页码(姓名=str(i))
sm.add_小部件(名称)
类TestApp(应用程序):
def生成(自):
返回sm
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
TestApp().run()
kivy版本1.8和1.9之间存在差异。不支持mp3格式,在1.8 kivy中处理错误,但在1.9中不支持!