Logo Search packages:      
Sourcecode: viridian version File versions  Download package

def AmpacheTools::AmpacheGUI::AmpacheGUI::__audioengine_song_changed (   self,
  song_id 
) [private]
The function that gets called when the AudioEngine changes songs.

Definition at line 2742 of file AmpacheGUI.py.

                                                   :
            """The function that gets called when the AudioEngine changes songs."""
            self.update_playlist_window()
02746             self.refresh_gui()
            if song_id == None: # nothing playing
                  self.current_song_info = None
                  self.play_pause_image.set_from_pixbuf(self.images_pixbuf_play)
                  self.set_tray_tooltip('Viridian')
                  self.window.set_title("Viridian")
                  self.set_tray_icon(None)
                  #self.update_playlist_window()
                  return False
            self.play_pause_image.set_from_pixbuf(self.images_pixbuf_pause)

            print self.current_song_info # DEBUG
            
            song_time   = self.current_song_info['song_time']
            self.time_elapsed_slider.set_range(0, song_time)
            self.time_total_label.set_text(helperfunctions.convert_seconds_to_human_readable(song_time))
            
            song_title  = self.current_song_info['song_title']
            artist_name = self.current_song_info['artist_name']
            album_name  = self.current_song_info['album_name']
            
            song_title_html  = helperfunctions.convert_string_to_html(song_title)
            artist_name_html = helperfunctions.convert_string_to_html(artist_name)
            album_name_html  = helperfunctions.convert_string_to_html(album_name)
            
            ### Update EVERYTHING to say the current artist, album, and song
            # make font size smaller if the title is long
            length = len(song_title_html)
            if length > 40:
                  self.current_song_label.set_markup('<span size="9000"><b>'+song_title_html+'</b></span>')
            elif length > 20:
                  self.current_song_label.set_markup('<span size="11000"><b>'+song_title_html+'</b></span>')
            else:
                  self.current_song_label.set_markup('<span size="13000"><b>'+song_title_html+'</b></span>')
            self.current_artist_label.set_markup( '<span size="10000">'+artist_name_html+'</span>' )
            self.current_album_label.set_markup(  '<span size="10000">'+album_name_html+'</span>'  )
            
            ### Update the statusbar and tray icon ###
            self.set_tray_tooltip("Viridian :: " + song_title + ' - ' + artist_name + ' - ' + album_name)
            self.update_statusbar(song_title + ' - ' + artist_name + ' - ' + album_name)
            self.window.set_title("Viridian :: " + song_title + ' - ' + artist_name + ' - ' + album_name)
            
            ### Get the album Art ###
            album_id   = self.current_song_info['album_id']
            if not os.path.exists(ALBUM_ART_DIR):
                  os.mkdir(ALBUM_ART_DIR)
            self.current_album_art_file = os.path.join(ALBUM_ART_DIR,  str(album_id))
            if os.path.isfile(self.current_album_art_file):
                  print "Album art exists locally"
            else:
                  print "Fetching album art... ",
                  album_art = self.ampache_conn.get_album_art(album_id)
                  response = urllib2.urlopen(album_art)
                  f = open(self.current_album_art_file, 'w')
                  f.write(response.read())
                  f.close()
                  print "Done!"
            # now create a pixel buffer for the image and set it in the GUI
            image_pixbuf = guifunctions.create_image_pixbuf(self.current_album_art_file, ALBUM_ART_SIZE)
            self.album_art_image.set_from_pixbuf(image_pixbuf)
            self.set_tray_icon(image_pixbuf)
            
            self.refresh_gui()
            
            ### Send notifications OSD ###
            self.notification(_("Now Playing"), song_title + ' - ' + artist_name + ' - ' + album_name, self.current_album_art_file)
            # rating stars
            stars = self.current_song_info['precise_rating']
            i = 0
            while i < 5:
                  if stars > i:
                        self.rating_stars_list[i].set_from_pixbuf(self.images_pixbuf_gold_star)
                  else:
                        self.rating_stars_list[i].set_from_pixbuf(self.images_pixbuf_gray_star)
                  i += 1
            
            ### Alert the plugins! ###
            thread.start_new_thread(self._alert_plugins_of_song_change, (None,))

            
      

Generated by  Doxygen 1.6.0   Back to index