internal static void UpdateSongInfo()
        {
            if (IsDefaultStaion)
            {
                ID3TagData TempID3 = new ID3TagData();

                using (WebClient client = new WebClient())
                {
                    SongInfo.CurrentSong = GetSong(client, SongInfo.RadioStation.Endpoints.Song);
                    while (true)
                    {
                        TempID3 = GetSong(client, SongInfo.RadioStation.Endpoints.Song);
                        if (SongInfo.CurrentSong.Artist != TempID3.Artist && SongInfo.CurrentSong.Title != TempID3.Title)
                        {
                            if (!SongInfo.IsContinuous)
                            {
                                if (RecordStreamThread.ThreadState == ThreadState.Running)
                                {
                                    RecordStreamThread.Abort();
                                }

                                Thread.Sleep(1000 * SongInfo.StreamDelay);

                                SongInfo.CurrentSong   = TempID3;
                                SongInfo.Elapsed.Value = 0;

                                if (RecordStreamThread.ThreadState == ThreadState.Aborted)
                                {
                                    if (Mp3Reader != null)
                                    {
                                        Mp3Reader = null;
                                    }
                                    if (Mp3Writer != null)
                                    {
                                        Mp3Writer = null;
                                    }

                                    RecordStreamThread = new Thread(RecordStream);
                                    RecordStreamThread.Start();
                                }
                            }
                        }
                        UpdateElapsed();
                    }
                }
            }
            else
            {
                while (true)
                {
                    UpdateElapsed();
                }
            }
        }
Example #2
0
        internal static bool CommandIsValid(string Line)
        {
            bool ret = false;

            switch (Line.ToLower())
            {
            case "play":
            case "pause":
            case "p":
                SongInfo.PlaybackState = SongInfo.PlaybackState == PlaybackState.Playing ? PlaybackState.Paused : PlaybackState.Playing;
                ret = true;
                break;

            case "start":
            case "stop":
            case "s":
                if (RecordStreamThread.ThreadState == ThreadState.Running)
                {
                    RecordStreamThread.Abort();
                }
                else
                {
                    RecordStreamThread = new Thread(RecordStream);
                    RecordStreamThread.Start();
                }
                ret = true;
                break;

            case "volume up":
            case "vu":
                if (SongInfo.Volume.Value < 100)
                {
                    SongInfo.Volume.Value += 5;
                }
                ret = true;
                break;

            case "volume down":
            case "vd":
                if (SongInfo.Volume.Value > 0)
                {
                    SongInfo.Volume.Value -= 5;
                }
                ret = true;
                break;

            case "mute":
            case "unmute":
            case "m":
                SongInfo.Volume.Muted = !SongInfo.Volume.Muted;
                ret = true;
                break;

            case "open":
            case "o":
                System.Diagnostics.Process.Start("explorer.exe", Path.Combine(Environment.CurrentDirectory, Regex.Replace(SongInfo.RadioStation.Name, "\\/", "-")));
                ret = true;
                break;

            case "del":
            case "d":
                Empty(Path.Combine(Environment.CurrentDirectory, Regex.Replace(SongInfo.RadioStation.Name, "\\/", "-")));
                ret = true;
                break;

            case "quit":
            case "q":
                Environment.Exit(0);
                break;

            default:
                UpdateConsoleLine(InvalidPos, $"Invalid command: {Line}");
                ret = false;
                break;
            }
            UpdateConsoleLine(CommandPos, "Enter a command:");
            UpdateConsoleLine(InputPos, "");

            return(ret);
        }