Esempio n. 1
0
class MusicLayout(FloatLayout):
    loadfile = ObjectProperty(None)
    ardSocket = ArduinoSocket(ip, 5000);

    def dismiss_popup(self):
        self._popup.dismiss()

    def show_load(self):
        content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
        self._popup = Popup(title="Load file", content=content, size_hint=(0.9, 0.9))
        self._popup.open()

    def show_warning(self):
        popup = Popup(title='Warning',
                      content=Label(text='No track loaded'),
                      size_hint=(0.2, 0.2))
        popup.open()
        
    def load(self, path, filename):
        try:
            print path
            print filename
            pb = ProgressBar(max=1000)
            self.ardMusic = ArduinoMusic(os.path.join(path, filename[0]), self.ardSocket)
        except:
            pass
        self.dismiss_popup()

    def startMusic(self):
        if hasattr(self,'ardMusic'):
            self.ardMusic.start()
        else:
            self.show_warning()

    def stopMusic(self):
        if hasattr(self,'ardMusic'):
            self.ardMusic.stop()
        else:
            self.show_warning()

    def pauseMusic(self):
        if hasattr(self,'ardMusic'):
            self.ardMusic.pause()
        else:
            self.show_warning()

    def unpauseMusic(self):
        if hasattr(self,'ardMusic'):
            self.ardMusic.play()
        else:
            self.show_warning()

    def shutdown(self):
        print "shutdown"
        self.ardSocket.sendPackage(self.ardSocket.SHUTDOWN, 0)

    def reconnect(self):
        self.ardSocket.close()
        self.ardSocket = ArduinoSocket(ip, 5000);
Esempio n. 2
0
 def load(self, path, filename):
     try:
         print path
         print filename
         pb = ProgressBar(max=1000)
         self.ardMusic = ArduinoMusic(os.path.join(path, filename[0]), self.ardSocket)
     except:
         pass
     self.dismiss_popup()