Beispiel #1
0
        static void Run()
        {
            using (PlayerBase <AudioItem> player = new Player())
            {
                player.LockStateChanged += (sender, e) =>
                {
                    PlayerView.UpdateScreen(player);
                    Console.WriteLine($"Lock state changed event : {e.IsLocked}");
                };
                player.VolumeChanged += (sender, e) =>
                {
                    PlayerView.UpdateScreen(player);
                    Console.WriteLine($"Volume changed event : {e.Volume}");
                };
                player.CollectionChanged += (sender, e) =>
                {
                    PlayerView.UpdateScreen(player);
                    Console.WriteLine($"Colection changed event");
                };
                player.PlayerPlayingStateChanged += (sender, e) =>
                {
                    PlayerView.UpdateScreen(player);
                    Console.WriteLine($"Started/Stopped event : {e.IsPlaying}");
                };
                player.PlaingItemStarted += (sender, e) =>
                {
                    PlayerView.UpdateScreen(player);
                    Console.WriteLine($"Started song event : {e.ItemTitle} {e.ItemDuration} {e.ItemDurationMinSec}");
                };

                player.Load(Environment.CurrentDirectory);
                Console.WriteLine("set song");
                player.SetPlayingItem();

                //Console.WriteLine("play");
                //player.Play();
                //Console.ReadLine();
                //Console.WriteLine("set volume");
                //player.Volume = 50;
                //Console.ReadLine();
                //Console.WriteLine("play");
                //player.Play();
                //Console.ReadLine();
                //Console.WriteLine("lock");
                //player.LockUnLock = true;
                //Console.ReadLine();
                //Console.WriteLine("play");
                //player.Play();
                //Console.ReadLine();
                //Console.WriteLine("unlock");
                //player.LockUnLock = false;
                //Console.ReadLine();


                while (true)
                {
                    player.LabelOutput("Next action:");
                    //Console.WriteLine("Next action :");
                    string cmd = Console.ReadLine();
                    switch (cmd)
                    {
                    case "set volume":
                        player.Volume = player.Volume;
                        break;

                    case "play":
                        player.Play();
                        //player.Playing = true; //error. Property or indexer 'Player.Plaing' cannot be assigned to -- it is read only
                        break;

                    case "stop":
                        player.Stop();
                        break;

                    case "lock":
                        player.LockUnLock = true;
                        break;

                    case "unlock":
                        player.LockUnLock = false;
                        break;

                    case "set song":
                        player.SetPlayingItem();
                        break;

                    case "pause":
                        player.Pause();
                        break;

                    case "show":
                        //player.ShowPlaylist();
                        break;

                    case "sort":
                        player.SortPlayList_ByTitle();
                        break;

                    case "genre filter":
                        //Console.WriteLine("Input Genre you want..");
                        //player.SongListGenreSort(Console.ReadLine().Trim().ToUpper());
                        (player as Player).Filter_ByGenre();
                        break;

                    case "shuffle":
                        player.ShufflePlayList();
                        break;

                    case "quit":
                        //player.ClosePlayer();
                        //player.Dispose();

                        //Environment.Exit(0);
                        return;

                    //break;

                    case "set like":
                        player.SetLike();
                        break;

                    case "set skin":
                        player.SetSkin();
                        break;

                    case "load":
                        Console.WriteLine("Enter path:");
                        player.Load(Console.ReadLine());
                        break;

                    case "clear":
                        player.Clear();
                        break;

                    case "save playlist":
                        Console.WriteLine("Enter playlist name:");
                        player.SavePlaylist(Console.ReadLine());
                        break;

                    case "load playlist":
                        Console.WriteLine("Enter path:");
                        player.LoadPlaylist(Console.ReadLine());
                        break;

                    default:
                        player.LabelOutput("Unknown command...");

                        break;
                    }
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            int    min, max, total = 0;
            Player player = new Player(new ClassicSkin());
            Random rand   = new Random();

            Console.WriteLine($"{0}");
            //var songs = CreateSongs(out min, out max, ref total);


            List <Song> songs = new List <Song>();

            for (int i = 0; i < 8; i++)
            {
                var song = CreateSong($"song {i}", Convert.ToBoolean(rand.Next(2)));
                songs.Add(song);
            }
            player.Add(songs);

            List <Song> songsGenre = new List <Song>();

            for (int i = 0; i < 8; i++)
            {
                var songG = CreateSongGenre($"song {i}", rand.Next(4));

                songsGenre.Add(songG);
            }
            player.Add(songsGenre);

            while (true)
            {
                switch (ReadLine())
                {
                case "up":
                {
                    player.VolumeUp();
                }
                break;

                case "down":
                {
                    player.VolumeDown();
                }
                break;

                case "p":
                {
                    player.Play(true);
                }
                break;

                case "l":
                {
                    player.Lock();
                }
                break;

                case "ul":
                {
                    player.Unlock();
                }
                break;

                case "s":
                {
                    player.Stop();
                }
                break;

                case "start":
                {
                    player.Start();
                }
                break;

                case "shuf":
                {
                    player.Shuffle(songs);
                }
                break;

                case "sort":
                {
                    player.SortByTitle(songs);
                }
                break;

                case "GS":
                {
                    player.FilterByGenre(songsGenre, Song.Genres.Pop);
                }
                break;

                case "CHS":
                {
                    player.ChangeSkin();
                }
                break;
                }
            }
            //player.Playing=true;
            Console.ReadLine();
        }
 private void StopClicked(object sender, RoutedEventArgs e)
 {
     _player.Stop();
 }
Beispiel #4
0
        private static void ManagePlayer(Player player)
        {
            while (true)
            {
                DisplayInfo();
                var cmd = GetCommand();
                switch (cmd)
                {
                    case "l":
                    case "load":
                        Console.WriteLine("Enter path to the playlist:");
                        var path = Console.ReadLine();
                        if (string.IsNullOrWhiteSpace(path))
                        {
                            Console.WriteLine("Invalid playlist path.");
                            continue;
                        }
                        try
                        {
                            var pl = DataContractFormatter<Playlist>.Load(path);
                            //todo: обработать исключения
                            player.LoadPlayList(pl);
                            Console.WriteLine("Playlist was loaded.");
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Playlist loading error!");
                        }
                        break;

                    case "pl":
                    case "play":
                        player.Play();
                        break;

                    case "pa":
                    case "pause":
                        player.Pause();
                        break;

                    case "s":
                    case "stop":
                        player.Stop();
                        break;

                    case "i":
                    case "info":
                        DisplayInfo();
                        break;

                    case "se":
                    case "select":
                        return;

                    case "e":
                    case "exit":
                        Environment.Exit(0);
                        return;
                    default:
                        Console.WriteLine("Incorrect command.");
                        continue;
                }
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            int min, max, total = 0;
            var player = new Player();
            var songs  = CreateSongs(out min, out max, ref total);

            player.Songs = songs;
            Console.WriteLine($"TotalDuration: {total}, max duration: {max}, min duration: {min}");

            while (true)
            {
                switch (ReadLine())
                {
                case "Up":
                {
                    player.VolumeUp();
                }
                break;

                case "Down":
                {
                    player.VolumeDown();
                }
                break;

                case "P":
                {
                    player.Play();
                }
                break;

                case "step1":
                {
                    player.VolumeChange1();
                }
                break;

                case "step2":
                {
                    player.VolumeChange2();
                }
                break;

                case "Lock":
                {
                    player.Lock();
                }
                break;

                case "Unlock":
                {
                    player.Unlock();
                }
                break;

                case "Stop":
                {
                    player.Stop();
                }
                break;

                case "Start":
                {
                    player.Start();
                }
                break;

                case "CreateDS":
                {
                    CreateDefaultSong();
                }
                break;
                }
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            var defaultSkin = new ColorSkin();

            using (var player = new Player(defaultSkin))
            {
                player.PlayerStartedEvent += (bool isPlaying) =>
                {
                    Visualise(player, player.PlayingPlaylist);
                };

                player.PlayerStoppedEvent += (bool isPlaying) =>
                {
                    List <Song> clearList = new List <Song>();
                    Visualise(player, clearList);
                };

                player.PlayerLockedEvent += (bool isLocked) =>
                {
                    Visualise(player, player.PlayingPlaylist);
                };

                player.PlayerUnlockedEvent += (bool isLocked) =>
                {
                    Visualise(player, player.PlayingPlaylist);
                };

                player.VolumeChangedEvent += (float inputAmount) =>
                {
                    Visualise(player, player.PlayingPlaylist);
                };

                player.SongStartedEvent += (Song song) =>
                {
                    Visualise(player, player.PlayingPlaylist);
                };

                player.SongStoppedEvent += (Song song) =>
                {
                    Visualise(player, player.PlayingPlaylist);
                };

                player.PlaybackAbortedEvent += (bool isAborted) =>
                {
                    Visualise(player, player.PlayingPlaylist);
                };

                while (true)
                {
                    switch (ReadLine())
                    {
                    case "u":
                    {
                        player.VolumeUp();
                    }
                    break;

                    case "d":
                    {
                        player.VolumeDown();
                    }
                    break;

                    case "Loop":
                    {
                        if (player.IsPlaying == false)
                        {
                            player.Start();
                        }
                        player.Play(true);
                    }
                    break;

                    case "-Loop":
                    {
                        player.IsOnLoop = false;
                    }
                    break;

                    case "P":
                    {
                        if (player.IsPlaying == false)
                        {
                            player.Start();
                        }
                        player.Play();
                    }
                    break;

                    case "V":
                    {
                        player.currentSkin.Render("Specify volume: ");
                        float inputAmount = Convert.ToSingle(Console.ReadLine().Replace('.', ','));
                        player.VolumeChange(inputAmount);
                    }
                    break;

                    case "Start":
                    {
                        player.Start();
                    }
                    break;

                    case "s":
                    {
                        player.Stop(player.currentPlaybackDevice);
                    }
                    break;

                    case "a":
                    {
                        player.Abort();
                    }
                    break;

                    case "Lock":
                    {
                        player.Lock();
                    }
                    break;

                    case "Unlock":
                    {
                        player.Unlock();
                    }
                    break;

                    case "Load":
                    {
                        player.currentSkin.Render("Please enter the path to desired directory");
                        string path = Console.ReadLine();
                        player.Load(path);
                    }
                    break;

                    case "Clear":
                    {
                        player.playlist.Songs.ClearAll();
                    }
                    break;

                    case "Shuffle":
                    {
                        player.playlist.Songs = player.Shuffle();
                    }
                    break;

                    case "SortT":
                    {
                        player.playlist.Songs = player.SortByTitle();
                    }
                    break;

                    case "+":
                    {
                        var input = Console.ReadLine();

                        for (int i = 0; i < player.playlist.Songs.Count; i++)
                        {
                            if (player.playlist.Songs[i].Title == input)
                            {
                                player.playlist.Songs[i].Like();
                            }
                        }
                    }
                    break;

                    case "-":
                    {
                        player.currentSkin.Render("Please specify the the title of a song in current playlist that you wish to like");
                        var input = Console.ReadLine();

                        for (int i = 0; i < player.playlist.Songs.Count; i++)
                        {
                            if (player.playlist.Songs[i].Title == input)
                            {
                                player.playlist.Songs[i].Dislike();
                            }
                        }
                    }
                    break;

                    case "SortG":
                    {
                        player.currentSkin.Render("Please specify genre");
                        string   input    = Console.ReadLine();
                        int      inputInt = 0;
                        string[] Genre    = { "PsyTrance", "Electronic", "Hardcore", "DnB", "Drumstep" };

                        for (int i = 0; i < 5; i++)
                        {
                            if (input == Genre[i])
                            {
                                inputInt = i;
                            }
                        }

                        player.playlist.Songs = player.FilterByGenre(inputInt);
                    }
                    break;

                    case "s 0":
                    {
                        var tempSkin = new ColorSkin();
                        player.currentSkin = tempSkin;
                        player.currentSkin.NewScreen();
                    }
                    break;

                    case "s 1":
                    {
                        var tempSkin = new ColorSkin(ConsoleColor.Blue);
                        player.currentSkin = tempSkin;
                        player.currentSkin.NewScreen();
                    }
                    break;

                    case "SaveP":
                    {
                        player.SaveCurrentPlaylist();
                    }
                    break;

                    case "LoadP":
                    {
                        player.LoadPlaylist();
                    }
                    break;

                    case "Exit":
                    {
                        player.Dispose();
                    }
                    break;
                    }
                }
            }
        }