Created
October 3, 2014 08:41
-
-
Save daryasary/f69e1d0444ae70ff5296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.uix.screenmanager import ScreenManager, Screen | |
from kivy.core.audio import SoundLoader,Sound | |
from kivy.lang import Builder | |
Builder.load_string(''' | |
<MenuPage>: | |
BoxLayout: | |
orientation:'vertical' | |
Button: | |
text:'play' | |
on_press:root.plays() | |
Button: | |
text:'stop' | |
on_press:root.stops() | |
''') | |
class Music(Sound): | |
def __init__(self): | |
self.sound = SoundLoader.load('/home/hosein/Music/Man.mp3') | |
class MenuPage(Screen): | |
def __init__(self): | |
self.M = Music() | |
def plays(self): | |
self.M.play() | |
def stops(self): | |
self.M.stop() | |
music = Music() | |
sm = ScreenManager() | |
menu = MenuPage(name='menu') | |
sm.add_widget(menu) | |
#if sound: | |
#print("Sound found at %s" % sound.source) | |
#print("Sound is %d seconds" % sound.length) | |
#print("Sound state is %s" % sound.state) | |
#sound.play() | |
class TestApp(App): | |
def build(self): | |
return sm | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment