kivy声音对win 8不起作用

时间:2014-11-23 06:21:16

标签: python linux windows kivy

我已经在ubuntu上测试了我的代码并且它正常工作但是当我在windows8上测试时,声音没有播放。

我编写了一个新的应用程序,但它也不起作用。窗户有特殊设置吗? 为什么我不能播放声音?

它将是一个移动应用程序但尚未完成。 问题是什么? 它可以在移动设备上运行吗?

这是我的代码:

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()

0 个答案:

没有答案