Exemplo n.º 1
0
        // FIXME: No reason for this to use GdkPixbuf - the file is on disk already in
        // the artwork cache as a JPEG, so just shove the bytes from disk into the track
        public static void SetIpodCoverArt(IPod.Device device, IPod.Track track, string path)
        {
            try {
                Gdk.Pixbuf pixbuf = null;
                foreach (IPod.ArtworkFormat format in device.LookupArtworkFormats(IPod.ArtworkUsage.Cover))
                {
                    if (!track.HasCoverArt(format))
                    {
                        // Lazily load the pixbuf
                        if (pixbuf == null)
                        {
                            pixbuf = new Gdk.Pixbuf(path);
                        }

                        track.SetCoverArt(format, IPod.ArtworkHelpers.ToBytes(format, pixbuf));
                    }
                }

                if (pixbuf != null)
                {
                    pixbuf.Dispose();
                }
            } catch (Exception e) {
                Log.Exception(String.Format("Failed to set cover art on iPod from {0}", path), e);
            }
        }