Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            CommandLine.Parser.Default.ParseArguments <Options>(args)
            .WithParsed <Options>(opts => options = opts)
            .WithNotParsed <Options>(errs => System.Environment.Exit(-1));

            myStreamSource = new StreamSource
            {
                DisplayName = "Radio Energy Nuremberg",
                FilePrefix  = "NRJ_Nuremberg",
                StreamUrl   = "http://energyradio.de/nuernberg"
            };

            myRipper = new Mp3StreamRipper();
            myRipper.StartRip(myStreamSource);

            var fileLocation = GetFileLocation();

            Console.WriteLine($"Writing to {fileLocation}");

            myRecorder = new Mp3StreamRecorder((Mp3StreamRipper)myRipper, fileLocation);
            myRecorder.StartRecord();

            var sw = new Stopwatch();

            sw.Start();
            do
            {
                Thread.Sleep(1000);
            }while (sw.Elapsed.TotalMinutes < options.Duration);

            myRecorder.StopRecord();
            myRipper.StopRip();

            Console.WriteLine("End World!");
        }
        public StreamRipperItemProxy(IStreamRipper streamRipper, Action <StreamRipperItemProxy> onDispose)
        {
            _streamRipper = streamRipper;
            _onDispose    = onDispose;

            MetadataChangedHandlers += (sender, arg) => _forks.ForEach(fork =>
            {
                if (fork.Active)
                {
                    fork.MetadataChangedHandlers.Invoke(sender, arg);
                }
            });

            StreamUpdateEventHandlers += (sender, arg) => _forks.ForEach(fork =>
            {
                if (fork.Active)
                {
                    fork.StreamUpdateEventHandlers.Invoke(sender, arg);
                }
            });

            StreamStartedEventHandlers += (sender, arg) => _forks.ForEach(fork =>
            {
                if (fork.Active)
                {
                    fork.StreamStartedEventHandlers.Invoke(sender, arg);
                }
            });

            StreamEndedEventHandlers += (sender, arg) => _forks.ForEach(fork =>
            {
                _running = false;

                if (fork.Active)
                {
                    fork.StreamEndedEventHandlers.Invoke(sender, arg);
                }
            });

            SongChangedEventHandlers += (sender, arg) => _forks.ForEach(fork =>
            {
                if (fork.Active)
                {
                    fork.SongChangedEventHandlers.Invoke(sender, arg);
                }
            });

            StreamFailedHandlers += (sender, arg) => _forks.ForEach(fork =>
            {
                _running = false;

                if (fork.Active)
                {
                    fork.StreamFailedHandlers.Invoke(sender, arg);
                }
            });

            _streamRipper.MetadataChangedHandlers    += MetadataChangedHandlers;
            _streamRipper.StreamUpdateEventHandlers  += StreamUpdateEventHandlers;
            _streamRipper.StreamStartedEventHandlers += StreamStartedEventHandlers;
            _streamRipper.StreamEndedEventHandlers   += StreamEndedEventHandlers;
            _streamRipper.SongChangedEventHandlers   += SongChangedEventHandlers;
            _streamRipper.StreamFailedHandlers       += StreamFailedHandlers;
        }