Exemple #1
0
        static void Main(string[] args)
        {
            Mediateka  myMediateka = new Mediateka();
            IMediaItem picture     = new DiscPicture("first", "E:\\picture1.jpg");
            IMediaItem track1      = new DiscTrack("look what u made me do", "pop", "E:\\track1.mp3");
            IMediaItem track2      = new DiscTrack("kek", "book", "E:\\track2.wav");
            IMediaItem track3      = new DiscTrack("test", "rock", "E:\\track2.wav");

            myMediateka.Add(picture);
            myMediateka.Add(track1);
            myMediateka.Add(track2);
            myMediateka.Add(track3);

            Player myPlayer = new Player(myMediateka);

            Console.ReadKey();
        }
Exemple #2
0
        private static Gdi GetGdiFromStringContent(IEnumerable <string> gdiContent)
        {
            gdiContent = gdiContent
                         .Where(l => !string.IsNullOrEmpty(l))
                         .Select(l => l.RemoveSpacesInSuccession());

            var gdi = new Gdi();

            int numberOfTracks;

            if (!int.TryParse(gdiContent.First(), out numberOfTracks))
            {
                throw new FormatException("The GDI file should have the number of tracks in its first line.");
            }

            if (numberOfTracks != (gdiContent.Count() - 1))
            {
                throw new FormatException("The number of tracks defined in the GDI file should match the number in the first line.");
            }

            gdi.NumberOfTracks = numberOfTracks;

            gdi.Tracks = new List <DiscTrack>();
            foreach (var line in gdiContent.Skip(1))
            {
                var lineSplittedBySpace = line.Split(" ");
                var discTrack           = new DiscTrack()
                {
                    TrackNumber = uint.Parse(lineSplittedBySpace.First()),
                    Lba         = uint.Parse(lineSplittedBySpace.ElementAt(1)),
                    TrackType   = byte.Parse(lineSplittedBySpace.ElementAt(2)),
                    SectorSize  = int.Parse(lineSplittedBySpace.ElementAt(3)),
                    FileName    = string.Join(" ", lineSplittedBySpace.Skip(4).SkipLast(1)).Replace("\"", string.Empty)
                };
                gdi.Tracks.Add(discTrack);
            }

            return(gdi);
        }