示例#1
0
 def stopPlaying(self):
     
     for speakerIp in self.sonos.get_speaker_ips():
         sonosSpeaker = SoCo(speakerIp)
         all_info = sonosSpeaker.get_speaker_info()
         for item in all_info:
             logging.info("Stopping for speaker %s: %s" % (item, all_info[item]))
         sonos.stop()
         LCDScreen.updateStatus("Sonos" , "Music Stopped" )
示例#2
0
 def handle(self, *args, **options):
     try:
         splash = SplashScreen()
         splash.ShowSplash()
         logging.info( 'Service command starting')
         svc = JukeboxService()
         svc.Run()
         logging.info( 'Service command ending')
     except:
         logging.error('Error running service %s' % sys.exc_info()[1])
         LCDScreen.updateStatus("ERROR",  str(sys.exc_info()[1]) )
示例#3
0
 def __init__(self):
     super(JukeboxService, self).__init__()
     try:
         self.signalReceiver = JukeboxSignalReceiver(self)
         self.keyProcessor = JukeboxKeyProcessor()
         self.signalReceiver.start()
         self.lastSignalTime = datetime.datetime.now()
         self.signalLock = threading.Lock()
     except:
         err =  str(sys.exc_info()[1])
         LCDScreen.updateStatus("ERR", err)
         logging.error('Error initialising jukebox service %s' % err)
示例#4
0
class SplashScreen(object):

    lcd = None
    
    def __init__(self):
        self.lcd = LCDScreen()
        self.lcd.start()

    def ShowSplash(self):
        self.lcd.screenOn()
        LCDScreen.updateStatus("Sonos Jukebox", "Coopes 2014")
        sleep(2)
        LCDScreen.updateStatus("Sonos Jukebox", "Starting....")
        sleep(1)
    def ProcessKey(self, shortCutKeys):
        logging.info('Sent short cut "%s"' % shortCutKeys)

        LCDScreen.updateStatus("Keys Received", shortCutKeys)

        try:
            shortCut = self.shortCutMgr.getShortCut(shortCutKeys)
        except:
            shortCut = None
            
        # Is this a known shortcut?
        if shortCut != None:
            
            LCDScreen.updateStatus("Shortcut", shortCut.track )
            speakerConfig = self.configMgr.getConifgItem( "TARGET_SPEAKER")
            
            logging.info('Short cut track is"%s" running from "%s"' % (shortCut.track, shortCut.type))
            logging.info('Successfully read speaker to send to as "%s"' % (speakerConfig.value))
            
            # tell sonos how to play its shortcut
            if shortCut.type =="Pandora":
                
                self.sonosPlayer = SonosForPandora()
                self.sonosPlayer.playStation(shortCut.track, speakerConfig.value)
            
            else:
                logging.error('Unsupported shortcut type %s' % shortCut.type )
                LCDScreen.updateStatus("ERROR", "UNK TYPE: %s" % shortCut.type )
                sleep(5)
            
            LCDScreen.updateStatus("Sonos Jukebox", "Ready....")
        
        else:
            logging.error('Shortcut not found for %s' % shortCutKeys )
            LCDScreen.updateStatus("ERROR", "UNK S/CUT: %s" % shortCutKeys )
            sleep(5)
示例#6
0
 def Run(self):
     logging.info( 'Jukebox Service running')
     self.lastSignalTime = datetime.datetime.now()
     LCDScreen.updateStatus("Sonos Jukebox", "Ready....")
 
     try:
         while 1:
             sleep(1)
             keyPress =  self.SignalsToKeyUpdater()
             # get any key , then process them !
             if keyPress != None :
                 logging.info( 'Key press waiting to be processed.  Sending to processor')
                 self.keyProcessor.ProcessKey(keyPress)
                 LCDScreen.updateStatus("Sonos Jukebox", "Ready....")
     except:
          err =  str(sys.exc_info()[1])
          LCDScreen.updateStatus("ERR", err)
          logging.error('Error processing keys %s' % err)
示例#7
0
   def playStation(self, stationNameLike, onSpeakerLike): 
 
       LCDScreen.updateStatus("Pandora", "Loading music")
       stationId = self.rpandora.getIdForStation(stationNameLike)
       stationName = self.rpandora.getNameForStation(stationNameLike)
       
       LCDScreen.updateStatus("Pl: %s"  % stationName, "On %s" % onSpeakerLike )
       
       for speakerIp in self.sonos.get_speaker_ips():
           try:
               sonosSpeaker = SoCo(str(speakerIp))
               all_info = sonosSpeaker.get_speaker_info()
               if onSpeakerLike in all_info['zone_name'] :
                   logging.info("Playing on speaker %s" % str(speakerIp))
                   sonosSpeaker.play_uri("pndrradio:%s" % str(stationId), '')
                   LCDScreen.updateStatus("Pl: %s"  % stationName, "On %s" % all_info['zone_name'] )
               else:
                   logging.info('Skipping player "%s"' % all_info['zone_name'])
           except:
               logging.error('Failed calling %s' % speakerIp)
示例#8
0
 def ShowSplash(self):
     self.lcd.screenOn()
     LCDScreen.updateStatus("Sonos Jukebox", "Coopes 2014")
     sleep(2)
     LCDScreen.updateStatus("Sonos Jukebox", "Starting....")
     sleep(1)
示例#9
0
 def __init__(self):
     self.lcd = LCDScreen()
     self.lcd.start()