private static void Main()
    {
        using(SimpleDisc disc = new SimpleDisc("/dev/hdc")) {

            // Actually ask the MB server for metadata. As soon as a SimpleDisc is instantiated,
            // a disc layout is created based on reading the CD TOC directly. This query updates
            // that layout. For applications where UI must be responsive, run this query in
            // a thread.

            // To set proxy server information, call disc.Client.SetProxy(server, port) before
            // calling this query

            disc.QueryCDMetadata();

            Console.WriteLine("Artist Name   : " + disc.ArtistName);
            Console.WriteLine("Album Name    : " + disc.AlbumName);
            Console.WriteLine("Cover Art URL : " + disc.CoverArtUrl);
            Console.WriteLine("Amazon ASIN   : " + disc.AmazonAsin);
            Console.WriteLine("Release Date  : " + disc.ReleaseDate);
            Console.WriteLine("");

            foreach(SimpleTrack track in disc) {
                Console.WriteLine("{0:00}: [{1} - {2}] {3}:{4:00} ({5})",
                    track.Index, track.Artist, track.Title,
                    track.Minutes, track.Seconds, track.Length);
            }
        }
    }
Beispiel #2
0
    private static void Main()
    {
        using (SimpleDisc disc = new SimpleDisc("/dev/hdc")) {
            // Actually ask the MB server for metadata. As soon as a SimpleDisc is instantiated,
            // a disc layout is created based on reading the CD TOC directly. This query updates
            // that layout. For applications where UI must be responsive, run this query in
            // a thread.

            // To set proxy server information, call disc.Client.SetProxy(server, port) before
            // calling this query

            disc.QueryCDMetadata();

            Console.WriteLine("Artist Name   : " + disc.ArtistName);
            Console.WriteLine("Album Name    : " + disc.AlbumName);
            Console.WriteLine("Cover Art URL : " + disc.CoverArtUrl);
            Console.WriteLine("Amazon ASIN   : " + disc.AmazonAsin);
            Console.WriteLine("Release Date  : " + disc.ReleaseDate);
            Console.WriteLine("");

            foreach (SimpleTrack track in disc)
            {
                Console.WriteLine("{0:00}: [{1} - {2}] {3}:{4:00} ({5})",
                                  track.Index, track.Artist, track.Title,
                                  track.Minutes, track.Seconds, track.Length);
            }
        }
    }
		public static void Test()
		{
			try
			{
				const string device = "/dev/hdc";
				using(SimpleDisc disc = new SimpleDisc(device))
				{
	           
					// Actually ask the MB server for metadata. As soon as a SimpleDisc is instantiated,
					// a disc layout is created based on reading the CD TOC directly. This query updates
					// that layout. For applications where UI must be responsive, run this query in
					// a thread.
	            
					// To set proxy server information, call disc.Client.SetProxy(server, port) before
					// calling this query
	            
					disc.QueryCDMetadata();
	        
					Debug.WriteLine("Artist Name   : " + disc.ArtistName);
					Debug.WriteLine("Album Name    : " + disc.AlbumName);
					Debug.WriteLine("Cover Art URL : " + disc.CoverArtUrl);
					Debug.WriteLine("Amazon ASIN   : " + disc.AmazonAsin);
					Debug.WriteLine("Release Date  : " + disc.ReleaseDate);
					Debug.WriteLine("");
	            
					foreach(MediaItem track in disc)
					{
						//string trackInfo = string.Format(CultureInfo.InvariantCulture, "{0:00}: [{1} - {2}] {3}:{4:00} ({5})", 
							//track.Index, track.Artist, track.Title, 
							//track.Minutes, track.Seconds, track.Length);
						//Debug.WriteLine(trackInfo);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.WriteLine("Error reading from CD: " + ex.Message);
				throw new ApplicationException("Error reading from CD", ex);
			}
		}
		private SimpleAlbum LookupAlbumByCompactDisc(Uri path)
		{
			SimpleAlbum album = null;

			if (path != null)
			{
				try
				{
					Debug.WriteLine("Drive Name:" + path.ToString());

					//"/dev/hdc" or D:
					string driveName = path.LocalPath;
					if (driveName.IndexOf(@"\") > -1)
					{
						driveName = driveName.Replace(@"\", string.Empty);
					}
					Debug.WriteLine("Cleaned up Drive Name: " + driveName);

					using (SimpleDisc simpleDisc = new SimpleDisc(driveName))
					{
						// Actually ask the MB server for metadata. As soon as a SimpleDisc is instantiated,
						// a disc layout is created based on reading the CD TOC directly. This query updates
						// that layout. For applications where UI must be responsive, run this query in
						// a thread.

						// To set proxy server information, call disc.Client.SetProxy(server, port) before
						// calling this query

						Debug.WriteLine("Before query CD metadata");
						simpleDisc.QueryCDMetadata();
						Debug.WriteLine("After query CD metadata");

						Debug.WriteLine("Artist Name   : " + simpleDisc.ArtistName);
						Debug.WriteLine("Album Name    : " + simpleDisc.AlbumName);
						Debug.WriteLine("Cover Art URL : " + simpleDisc.CoverArtUrl);
						Debug.WriteLine("Amazon ASIN   : " + simpleDisc.AmazonAsin);
						Debug.WriteLine("Release Date  : " + simpleDisc.ReleaseDate);
						Debug.WriteLine("");

						album = new SimpleAlbum(Guid.NewGuid(), simpleDisc.AlbumName, simpleDisc.ArtistName, simpleDisc.ReleaseDate, path);
						foreach (MediaItem track in simpleDisc.Tracks)
						{
							//track.Parent = album;
							album.Items.Add(track);
								//track.Number, track);
						}

						/*
						AlexandriaOrg.Alexandria.Data.Artist artist = new AlexandriaOrg.Alexandria.Data.Artist();
						artist.Name = disc.ArtistName;

						System.Diagnostics.Debug.WriteLine("AlbumId=" + disc.AlbumId);					
						album = new AlexandriaOrg.Alexandria.Data.Album();
						album.MusicBrainzId = disc.AlbumId;
						album.MusicBrainzUrl = disc.AlbumUrl;
						album.Name = disc.AlbumName;
						album.Artist = artist;
						album.AmazonAsin = disc.AmazonAsin;
						album.CoverArtUrl = disc.CoverArtUrl;

						foreach (SimpleTrack simpleTrack in disc)
						{
							string trackInfo = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:00}: {1} - {2} {3}:{4:00} ({5})",
								simpleTrack.Index, simpleTrack.Artist, simpleTrack.Title,
								simpleTrack.Minutes, simpleTrack.Seconds, simpleTrack.Length);
							Debug.WriteLine(trackInfo);
							Alexandria.Data.Track track = new AlexandriaOrg.Alexandria.Data.Track();
							
							Alexandria.Data.Artist trackArtist = new AlexandriaOrg.Alexandria.Data.Artist();
							trackArtist.Name = simpleTrack.Artist;
							
							track.Album = album;
							track.Artist = trackArtist;
							track.Length = (uint)simpleTrack.Length;
							track.Name = simpleTrack.Title;
							track.Milliseconds = Convert.ToUInt32((simpleTrack.Minutes * 60000) + (simpleTrack.Seconds * 1000));
							track.Number = Convert.ToUInt32(simpleTrack.Index);
							album.Tracks.Add(track.Number, track);
						}
						*/
					}
				}
				catch (Exception ex)
				{
					//Debug.WriteLine("Error reading from CD: " + ex.Message);
					throw new ApplicationException("Error reading from CD", ex);
				}
			}
			else throw new ArgumentNullException("drive");

			return album;
		}