Beispiel #1
0
    def onSelected(self):
        if self.state == "":
            self.state = "on duty"
            system.startCommand(
                " sudo abcde -N & ")  # works with sudo ? to be tested
        else:
            self.state = ""
            system.startCommand(" pkill abcde ; pkill cdpara ")

        self.name = "Ripping " + self.state
Beispiel #2
0
    def populate(self):
        self.clearEntries()
        system.startCommand("mpc update")
        allArtists = system.startReturnCommand("/usr/bin/mpc list AlbumArtist")

        self.clearEntries()
        for name in allArtists:
            if name.strip("") != "":
                artist = Artist(self, name)
                self.addEntry(artist)
Beispiel #3
0
    def update(self, key, data):
        system.putToShelf(key, data)
        if key == "magicMode":
            return

        if key == "mpcVol":
            system.startCommand("mpc volume " + str(data))

        if key == "bluetooth":
            return

        if key == "wifi":
            return
Beispiel #4
0
    def onSelected(self):
        SubMenu.onSelected(self)

        if self.loaded == False:
            system.mpcClear()
            for i in range(len(self.parent.tracks)):
                system.startCommand("mpc add cdda:///" + str(i + 1))

            self.loaded = True
            self.resetHelper()

        if self.play == False:
            system.mpcPlay()
            self.mpcH.updateView()
        else:
            system.mpcPause()
            self.mpcH.updateView()

        self.play = not self.play
Beispiel #5
0
    def askNewVolume(self, dec):
        """ must be changed to fulfill with updateView patern asked from _main thread in update is required
        :param dec:
        :return:
        """
        "if current submenu is a setting menu ; this control is used to modify the property"
        if self.menu.isSettingShown() and self.mode == MODE_LOCAL:
            self.menu.currentSub.subMenuShown().update(dec)
            return

        # if still here, it means we must modify the volume
        # constants
        minVol = 0
        maxVol = 100

        maxDec = 18
        ndec = max(min(maxDec, dec * 2), -maxDec)
        self.volume = min(maxVol, max(minVol, self.volume + ndec))
        self.io.writeText(" Vol : " + str(self.volume), 4)
        """
        if kind==BIG :
            system.startCommand("amixer -c 0 -q -- set Digital "+str(self.volume)+"dB")
        else :
            # this hack is because hifiberry mini amp does not have a proper hardware mixer ; I would prefer a better and simpler solution !
            if self.mode == MODE_SNAPSTREAM_IN or self.mode == MODE_SNAPSTREAM_OUT:
                system.startCommand("mpc volume 70" ) # default volume : to be changed
                system.startCommand("bash /home/pi/os/scripts/setSnapVolume.sh "+self.macAdrr+" "+str(100 + 2 * newVol))       ############### to be changed !!! it is not only piMain who streams
            else:
                system.startCommand("mpc volume " + str(100 + 2 * newVol))
        """
        if self.mode == MODE_SNAPSTREAM_IN or self.mode == MODE_SNAPSTREAM_OUT:
            # it means that we are streaming or receiving stream
            system.mpcVolume(100)
            # in this case, mpd is put at max and we thus modify snapclient volume with the following awfull bash script
            realVol = self.mpcToSnapVolumConvert(self.volume)
            system.startCommand(
                "bash /home/pi/os/scripts/setSnapVolume.sh " + self.macAdrr +
                " " + self.streamSource + " " + str(realVol)
            )  ############### te be changed !!! it is not only piMain who streams
        else:
            # here, we directly modify mpd volume
            system.mpcVolume(self.volume)
Beispiel #6
0
    def onSelected(self):
        SubMenu.onSelected(self)

        # if content is not yet loaded in mpc, mpc playlist is cleared and then content is loaded
        # mpc helper is also started

        if self.loaded == False:
            system.mpcClear()
            cmd = "mpc search Album  \"" + self.name + "\" albumartist \"" + self.parent.name + "\" | mpc add"
            system.startCommand(cmd)
            self.loaded = True
            self.resetHelper()

        if self.play:
            system.mpcPause()
            self.mpcH.updateView()
            self.play = False
        else:
            system.mpcPlay()
            self.mpcH.updateView()
            self.play = True
Beispiel #7
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 #8
0
 def _safeStop(self, shutdown=False):
     """
     This function should never be called directelly. The programm might be stopped by ending the _main io loop : io.goOn=False
     :param shutdown:
     :return:
     """
     system.logInfo("finishing")
     self.io.writeText("Exiting", 1)
     system.startCommand("mpc stop")
     system.startCommand("mpc clear")
     self.io.closeIO()
     system.closeShelf()
     self.io.writeText("power off", 1)
     system.logInfo("finished safely")
     if shutdown:
         system.startCommand("sudo reboot")
Beispiel #9
0
 def onSelected(self):
     self.getAncestorMenu().back()
     self.getAncestorMenu()
     self.getAncestorMenu().askRefreshFromOutside()
     system.startCommand("sudo eject &")
     self.getAncestorMenu().os.setCDInside(False)
Beispiel #10
0
    def onShowed(self):
        SubMenu.onShowed(self)

        system.mpcClear()
        system.startCommand("mpc add \"" + self.webAddr + "\"")
        system.mpcPlay()
Beispiel #11
0
 def _back(self):
     system.startCommand("mpc clear")
     return SubMenu._back(self)