Exemplo n.º 1
0
 def set_current_cover(self, try_web=True, force_song=None):            
     if not force_song:
         force_song = self.current_song
     filename = CoverManager.get_cover(force_song, try_web)    
     if Player.song != force_song:
         return False
     
     if not filename:
         if not try_web:
             if force_song.get_type() == "webcast":
                 pixbuf = utils.get_optimum_pixbuf(self.webcast_dpixbuf.get_pixbuf(), 
                                                   COVER_SIZE["x"], COVER_SIZE["y"])
                 self.start_animation(pixbuf, is_default=True)
                 return True
             else:    
                 pixbuf = utils.get_optimum_pixbuf(self.local_dpixbuf.get_pixbuf(), 
                                                   COVER_SIZE["x"], COVER_SIZE["y"])
                 self.start_animation(pixbuf, is_default=True)
                 return False
         return False    
     else:
         try:
             pixbuf = get_optimum_pixbuf_from_file(filename, 
                                                   COVER_SIZE["x"], COVER_SIZE["y"])
         except gobject.GError:    
             return False
         else:
             self.start_animation(pixbuf, is_default=False)
             return True
Exemplo n.º 2
0
    def set_current_cover(self, try_web=True, force_song=None):
        if not force_song:
            force_song = self.current_song
        filename = CoverManager.get_cover(force_song, try_web)
        if Player.song != force_song:
            return False

        if not filename:
            if not try_web:
                if force_song.get_type() == "webcast":
                    pixbuf = utils.get_optimum_pixbuf(
                        self.webcast_dpixbuf.get_pixbuf(), COVER_SIZE["x"],
                        COVER_SIZE["y"])
                    self.start_animation(pixbuf, is_default=True)
                    return True
                else:
                    pixbuf = utils.get_optimum_pixbuf(
                        self.local_dpixbuf.get_pixbuf(), COVER_SIZE["x"],
                        COVER_SIZE["y"])
                    self.start_animation(pixbuf, is_default=True)
                    return False
            return False
        else:
            try:
                pixbuf = get_optimum_pixbuf_from_file(filename,
                                                      COVER_SIZE["x"],
                                                      COVER_SIZE["y"])
            except gobject.GError:
                return False
            else:
                self.start_animation(pixbuf, is_default=False)
                return True
Exemplo n.º 3
0
    def __get_metadata(self, song):
        meta = {}

        if song is not None:
            ## MPRIS v2 meta map, defined at http://xmms2.org/wiki/MPRIS_Metadata

            meta['mpris:trackid'] = dbus.ObjectPath(self._get_trackid(song))
            meta['xesam:url'] = song.get_str("uri")
            meta['xesam:title'] = song.get_str("title")
            artist = song.get_str("artist")
            if artist:
                meta['xesam:artist'] = dbus.types.Array([artist],
                                                        signature='s')

            album = song.get_str("album")
            if album:
                meta['xesam:album'] = album

            genre = song.get_str("genre")
            if genre:
                meta['xesam:genre'] = dbus.types.Array([genre], signature='s')

            tracklen = song.get("#duration")
            if tracklen:
                meta['mpris:length'] = dbus.types.Int64(tracklen / 1000 *
                                                        MICROSECOND)

            # this is a workaround, write data to a tmp file and return name
            meta['mpris:artUrl'] = "file://" + (CoverManager.get_cover(
                song, False) or CoverManager.default_cover)

        return dbus.types.Dictionary(meta, signature='sv', variant_level=1)
    def __get_metadata(self, song):
        meta = {}

        if song is not None:
            ## MPRIS v2 meta map, defined at http://xmms2.org/wiki/MPRIS_Metadata

            meta['mpris:trackid'] = dbus.ObjectPath(self._get_trackid(song))
            meta['xesam:url'] = song.get_str("uri")
            meta['xesam:title'] = song.get_str("title")
            artist = song.get_str("artist")
            if artist:
                meta['xesam:artist'] = dbus.types.Array([artist], signature='s')

            album = song.get_str("album")
            if album:
                meta['xesam:album'] = album

            genre = song.get_str("genre")
            if genre:
                meta['xesam:genre'] = dbus.types.Array([genre], signature='s')

            tracklen = song.get("#duration")
            if tracklen:
                meta['mpris:length'] = dbus.types.Int64(tracklen / 1000 * MICROSECOND)

            # this is a workaround, write data to a tmp file and return name
            meta['mpris:artUrl'] = "file://" + (CoverManager.get_cover(song, False) or CoverManager.default_cover)

        return dbus.types.Dictionary(meta, signature='sv', variant_level=1)
Exemplo n.º 5
0
 def set_current_cover(self, try_web=True, force_song=None):            
     if not force_song:
         force_song = self.current_song
     filename = CoverManager.get_cover(force_song, try_web)    
     try:
         pixbuf = get_optimum_pixbuf_from_file(filename, COVER_SIZE["x"], COVER_SIZE["y"])
     except gobject.GError:    
         pass
     else:
         self.current_cover_pixbuf = pixbuf
         self.queue_draw()            
         del pixbuf
         if not try_web:
             return CoverManager.default_cover != filename
Exemplo n.º 6
0
 def instant_update_cover(self, widget, song):    
     if not CoverManager.get_cover(song, False):
         self.update_default_cover(widget, song)
     else:    
         self.update_cover(widget, song)