Пример #1
0
        public static IPod.Device [] ListDevices()
        {
            IPod.Device[] array = new IPod.Device[DeviceEventListener.Devices.Count];
            DeviceEventListener.Devices.CopyTo(array, 0);

            return(array);
        }
Пример #2
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);
            }
        }
Пример #3
0
        private static void watcherWindow_DeviceArrived(object sender, DeviceWindowEventArgs e)
        {
            foreach (char dr in e.Drives)
            {
                if (IsIpodDrive(dr))
                {
                    IPod.Device device = new IPod.Device(dr + ":\\");
                    devices.Add(dr, device);

                    if (device_added != null)
                    {
                        device_added(null, new DeviceEventArgs(device));
                    }
                }
            }
        }
Пример #4
0
        private static void watcherWindow_DeviceRemoved(object sender, DeviceWindowEventArgs e)
        {
            foreach (char dr in e.Drives)
            {
                if (devices.ContainsKey(dr))
                {
                    IPod.Device device = devices[dr];

                    devices.Remove(dr);

                    if (device_removed != null)
                    {
                        device_removed(null, new DeviceEventArgs(device));
                    }
                }
            }
        }
Пример #5
0
 internal DeviceEventArgs(IPod.Device Device)
 {
     _device = Device;
 }
Пример #6
0
        private static void watcherWindow_DeviceArrived(object sender, DeviceWindowEventArgs e)
        {
            foreach (char dr in e.Drives) {
                if (IsIpodDrive(dr))
                {
                    IPod.Device device = new IPod.Device(dr + ":\\");
                    devices.Add (dr, device);

                    if (device_added != null)
                        device_added (null, new DeviceEventArgs(device));
                }
            }
        }
Пример #7
0
        public void CommitToIpod(IPod.Device device)
        {
            track      = track ?? device.TrackDatabase.CreateTrack();
            ExternalId = track.Id;

            try {
                track.Uri = new Uri(Uri.AbsoluteUri);
            } catch (Exception e) {
                Log.Exception("Failed to create System.Uri for iPod track", e);
                device.TrackDatabase.RemoveTrack(track);
            }

            track.AlbumArtist   = AlbumArtist;
            track.BitRate       = BitRate;
            track.BPM           = (short)Bpm;
            track.Comment       = Comment;
            track.Composer      = Composer;
            track.DateAdded     = DateAdded;
            track.TotalDiscs    = DiscCount;
            track.DiscNumber    = DiscNumber;
            track.Duration      = Duration;
            track.Size          = (int)FileSize;
            track.Grouping      = Grouping;
            track.IsCompilation = IsCompilation;
            track.LastPlayed    = LastPlayed;
            track.PlayCount     = PlayCount;
            track.TotalTracks   = TrackCount;
            track.TrackNumber   = TrackNumber;
            track.Year          = Year;
            track.DateReleased  = ReleaseDate;

            track.Album  = AlbumTitle;
            track.Artist = ArtistName;
            track.Title  = TrackTitle;
            track.Genre  = Genre;

            switch (Rating)
            {
            case 1: track.Rating = IPod.TrackRating.Zero; break;

            case 2: track.Rating = IPod.TrackRating.Two; break;

            case 3: track.Rating = IPod.TrackRating.Three; break;

            case 4: track.Rating = IPod.TrackRating.Four; break;

            case 5: track.Rating = IPod.TrackRating.Five; break;

            default: track.Rating = IPod.TrackRating.Zero; break;
            }

            if (HasAttribute(TrackMediaAttributes.Podcast))
            {
                track.DateReleased     = ReleaseDate;
                track.Description      = description;
                track.RememberPosition = true;
                track.NotPlayedMark    = track.PlayCount == 0;
            }

            if (HasAttribute(TrackMediaAttributes.VideoStream))
            {
                if (HasAttribute(TrackMediaAttributes.Podcast))
                {
                    track.Type = IPod.MediaType.VideoPodcast;
                }
                else if (HasAttribute(TrackMediaAttributes.Music))
                {
                    track.Type = IPod.MediaType.MusicVideo;
                }
                else if (HasAttribute(TrackMediaAttributes.Movie))
                {
                    track.Type = IPod.MediaType.Movie;
                }
                else if (HasAttribute(TrackMediaAttributes.TvShow))
                {
                    track.Type = IPod.MediaType.TVShow;
                }
                else
                {
                    track.Type = IPod.MediaType.Video;
                }
            }
            else
            {
                if (HasAttribute(TrackMediaAttributes.Podcast))
                {
                    track.Type = IPod.MediaType.Podcast;
                }
                else if (HasAttribute(TrackMediaAttributes.AudioBook))
                {
                    track.Type = IPod.MediaType.Audiobook;
                }
                else if (HasAttribute(TrackMediaAttributes.Music))
                {
                    track.Type = IPod.MediaType.Audio;
                }
                else
                {
                    track.Type = IPod.MediaType.Audio;
                }
            }

            if (CoverArtSpec.CoverExists(ArtworkId))
            {
                SetIpodCoverArt(device, track, CoverArtSpec.GetPath(ArtworkId));
            }
        }
Пример #8
0
 internal DeviceEventArgs(IPod.Device Device)
 {
     _device = Device;
 }
Пример #9
0
        public static IPod.Device[] ListDevices()
        {
            IPod.Device[] array = new IPod.Device[DeviceEventListener.Devices.Count];
            DeviceEventListener.Devices.CopyTo(array,0);

            return array;
        }