예제 #1
0
def on_playing(obj):
  global alsamixer
  
  if control_center.ccchange("volume"):
    alsamixer.setvolume( int(math.log10(control_center.ccget("volume")*100.0) / 0.02) )
    
  if control_center.ccget("next"):
    control_center.ccset("next",False)
    obj.next()
  
  if control_center.ccchange("playing"):
    if control_center.ccget("playing"):
      obj.resume()
    else:
      obj.pause()
      write_led2("p")
  
  if control_center.ccchange("channel"):
    obj.play_list = []
    obj.next()
  
  try:
    dur = obj.cur_song['length']
    if dur == 0:
      dur = int(obj.player.query_duration(gst.FORMAT_TIME, None)[0] / 1000000000)
    
    pos = int(obj.player.query_position(gst.FORMAT_TIME, None)[0] / 1000000000)
  except Exception, e:
    print "+++++++++++++++",e
    dur,pos = 0,0
예제 #2
0
파일: ce.py 프로젝트: crane-may/cat_ear
 def play(self,uri):
     self.player.set_state(gst.STATE_NULL)
     self.player.set_property("uri", uri)
     self.player.set_state(gst.STATE_PLAYING)
     self.is_playing = True
     self.is_pause = False
     
     waiting = 0
     while self.is_playing:
         if control_center.ccchange("volume"):
             volume(control_center.ccget("volume"))
         
         if control_center.ccget("next"):
             control_center.ccset("next",False)
             mute(True)
             self.player.set_state(gst.STATE_NULL)
             self.is_playing = False
         
         if control_center.ccchange("playing"):
             if control_center.ccget("playing"):
                 self.player.set_state(gst.STATE_PLAYING)
                 self.is_pause = False
                 mute(False)
             else:
                 self.player.set_state(gst.STATE_PAUSED)
                 self.is_pause = True
                 mute(True)
         
         if control_center.ccchange("channel"):
             self.play_list = []
             mute(True)
             self.player.set_state(gst.STATE_NULL)
             self.is_playing = False
         
         if waiting % 10 == 0:
             try:
                 dur = self.cur_song['length']
                 if dur == 0:
                     dur = int(self.player.query_duration(gst.FORMAT_TIME, None)[0] / 1000000000)
                 
                 pos = int(self.player.query_position(gst.FORMAT_TIME, None)[0] / 1000000000)
                 
                 print "%s / %s %f @%f"%(self.convert_s(pos), self.convert_s(dur), 1.0 - pos * 1.0 / dur, control_center.ccget("volume"))
                 
                 if not self.is_pause:
                   write_led2("%d"%(dur - pos))
                   mute(False)
                 else:
                   write_led2("p")
             except Exception, e:
                 print "+++++++++++++++",e
                 print "00:00 / 00:00"
                 write_led2("")
                 
         time.sleep(0.1)
         waiting += 1
예제 #3
0
파일: ce.py 프로젝트: crane-may/cat_ear
 def start(self):
     control_center.ccchange("channel")
     while True:
         try:
             if len(self.play_list) == 0:
                 self.fetch_playlist()
             self.cur_song = self.play_list.pop()
             
             control_center.ccset("db_cur_song",json.dumps(self.cur_song))
             
             print "play ===",self.cur_song
             write_led2("")
             self.play(self.cur_song["url"])
         except Exception, e:
             print "="*100
             print e
             time.sleep(10)
예제 #4
0
파일: ce2.py 프로젝트: crane-may/cat_ear
def control():
	global sig_play_over
	if control_center.ccget("next"):
		control_center.ccset("next",False)
		sig_play_over = True
		
	if control_center.ccchange("playing"):
		if control_center.ccget("playing"):
			resume()
		else:
			pause()