Beispiel #1
0
 def answerToQuestion(self, question, sender):
     logDebug(" somebody (" + sender + ") asked " + question)
     if question == ASK_ISPLAYING:
         if isMPDPlaying():
             return ASW_TRUE
         else:
             return ASW_FALSE
Beispiel #2
0
    def initMPD(self):

        system.switchToLocalOutput()

        try:
            self.volume = system.getDataFromShelf("MPDVolume")
            system.logDebug("found volume ", self.volume)
        except:
            self.volume = 85
            system.logDebug("default volume ", self.volume)

        self.changeMode(MODE_LOCAL)
        system.startCommand("mpc update")
        system.startCommand("mpc clear")  # clear last mpd playlist
        system.startCommand("mpc stop")
Beispiel #3
0
    def askButtonAction(self, value):
        if self.mode == MODE_LOCAL or MODE_SNAPSTREAM_OUT:
            system.logDebug("ask button called : ", value)

            if value == 1:
                """
                mpd content in every room (snapcast)
                """

                if self.mode == MODE_LOCAL:
                    #
                    if system.isMPDPlaying():
                        # if local music is played
                        self.startOutputtingToSnapCast()
                    else:
                        # if no local music is played, we check wether other remotes play music
                        dest = []
                        for d in self.io.remoteNames:
                            if "local" not in d:
                                # this prevent remotes controls with name in xxx.local
                                dest.append(d)

                        for remote, answer in self.io.askMessageTo(
                                ASK_ISPLAYING, dest).items():

                            if answer == ASW_TRUE:
                                # we sync to the first remote which plays music
                                system.logDebug("starting listening to " +
                                                remote)
                                self.io.sendMessageTo(
                                    MSG_ORDER + sep + str(ORDER_STARTEMIT),
                                    remote)
                                self.startListeningToSnapCast(remote)
                                break

                        system.logDebug("")

                elif self.mode == MODE_SNAPSTREAM_OUT:
                    self.stopOutputtingToSnapCast()

                elif self.mode == MODE_SNAPSTREAM_IN:
                    self.stopListeningToSnapCast()

            elif value == 2:
                # mute other devices and stop snapcast if needed
                self.io.sendMessageToAll(MSG_ORDER + sep + str(ORDER_STOP))

            elif value == 3:
                self.menu.forceRadio()

            elif value == 4:
                self.io.connect._restartUDP()
Beispiel #4
0
    def askedOrder(self, value, source):
        """
        function called when specific order are received from remotes
        :param value: the kind of order received
        :param source: the remote which sent the order
        :return: nothing
        """

        self.markTime()
        if value == ORDER_STARTEMIT:
            if self.mode == MODE_LOCAL:
                system.logDebug("asked to start streaming music")
                self.startOutputtingToSnapCast()
            return

        if value == ORDER_SSYNC:
            if self.mode == MODE_LOCAL:
                self.startListeningToSnapCast(source)
            return

        if value == ORDER_SSTOP:
            if self.mode == MODE_SNAPSTREAM_IN:
                self.stopListeningToSnapCast()
            return

        if value == ORDER_STOP:
            if self.mode == MODE_SNAPSTREAM_OUT:
                system.logDebug("       asked to stop streaming")
                self.stopOutputtingToSnapCast()

            if self.mode == MODE_SNAPSTREAM_IN:
                system.logDebug("       asked to stop listening")
                self.stopListeningToSnapCast()

            if system.isMPDPlaying():
                self.askBack(1)  # we can maybe do better no ?
Beispiel #5
0
 def authorizedDetect(self):
     for faceButton in self.buttons:
         faceButton.getSwitch(
         )  # read buttons states for the first time to purge their states
     logDebug("starting button detection")
     self.detect = True