예제 #1
0
 private void listItems_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Delete)
     {
         if (listItems.SelectedIndex >= 0)
         {
             fpPlaylist playlist     = displayPlaylist;
             fpPlayItem playItem     = playlist.list[listItems.SelectedIndex];
             bool       shouldResume = false;
             if (playerDB.getCurrentItem() == playItem && playerState == PlayerState.Playing)
             {
                 stop();
                 shouldResume = true;
             }
             playlist.list.RemoveAt(listItems.SelectedIndex);
             playerDB.newRandomList();
             listItems.Items.Refresh();
             if (shouldResume)
             {
                 if (playerDB.playitemIndex >= playlist.list.Count)
                 {
                     playerDB.playitemIndex = 0;
                 }
                 loadPlayerItem();
             }
         }
     }
 }
예제 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            /*
             * var url = "https://raw.githubusercontent.com/dohProject/DLCachePlayer/master/DLCachePlayerDemo/Sample/3.%20Departures%20(alac%20file).m4a";
             * using (var mf = new MediaFoundationReader(url))
             * {
             *
             *  using (var wo = new WaveOutEvent())
             *  {
             *      wo.Init(mf);
             *      wo.Play();
             *      while (wo.PlaybackState == PlaybackState.Playing)
             *      {
             *          System.Threading.Thread.Sleep(1000);
             *      }
             *  }
             * }
             */


            if (File.Exists(DBPath))
            {
                readDB();
            }
            if (playerDB == null)
            {
                initPlaylist();
            }
            setRandomMode(playerDB.RandomMode);
            setLoopMode(playerDB.loopMode);
            sliderVolume.Value       = playerDB.volume;
            checkAutoPause.IsChecked = playerDB.autoPause;
            playerDB.checkDB();
            if (playerDB.playlists.Count > 0)
            {
                displayPlaylist          = playerDB.currentPlaylist;
                listItems.ItemsSource    = displayPlaylist.list;
                listPlaylist.ItemsSource = playerDB.playlists;
                loadPlayitemMetadata();
            }

            if (audioPlayer == null)
            {
                audioPlayer = new WaveOutEvent();
                audioPlayer.PlaybackStopped += AudioPlayer_PlaybackStopped;
            }
            audioPlayer.Volume = playerDB.volume;

            timerProgress           = new Timer();
            timerProgress.Interval  = 1000;
            timerProgress.AutoReset = true;
            timerProgress.Elapsed  += TimerProgress_Elapsed;
            timerProgress.Start();
            activeAutoPauseTimer(null, null);
        }
예제 #3
0
        private void btnAddPlaylist_Clicked(object sender, RoutedEventArgs e)
        {
            InputDialog dialog = new InputDialog(DialogType.Create, null);
            bool        result = dialog.ShowDialog() == true;

            if (result)
            {
                string     name     = dialog.tbInput1.Text;
                fpPlaylist playlist = new fpPlaylist()
                {
                    name = name
                };
                playerDB.playlists.Add(playlist);
                writeDB();
                listPlaylist.Items.Refresh();
            }
        }
예제 #4
0
        void initPlaylist()
        {
            playerDB           = new FPlayerDataBase();
            playerDB.playlists = new List <fpPlaylist>();
            fpPlaylist playlist = new fpPlaylist()
            {
                name = "播放清單"
            };

            playlist.list.Add(new fpPlayItem()
            {
                path = @"24. Life Will Change -instrumental version-.m4a"
            });
            playerDB.playlists.Add(playlist);
            playerDB.loopMode   = PlayerLoopMode.Loop;
            playerDB.RandomMode = PlayerRandomMode.Random;
            writeDB();
        }
예제 #5
0
        private void Window_Drop(object sender, DragEventArgs e)
        {
            if (playerDB.playlistIndex >= playerDB.playlists.Count)
            {
                return;
            }
            fpPlaylist playlist   = displayPlaylist;
            int        savedCount = playlist.list.Count;
            var        paths      = ((System.Array)e.Data.GetData(DataFormats.FileDrop));

            if (paths == null)
            {
                return;
            }
            for (int i = 0; i < paths.Length; i++)
            {
                string path  = paths.GetValue(i).ToString();
                Track  track = new Track(path);
                if (track.Duration > 0)
                {
                    fpPlayItem item = new fpPlayItem()
                    {
                        path   = path,
                        Name   = track.Title,
                        Artist = track.Artist,
                        Album  = track.Album
                    };
                    if (!playlist.list.Any(playItem => playItem.path == item.path))
                    {
                        playlist.list.Add(item);
                    }
                    listItems.Items.Refresh();
                }
            }
            if (playlist.list.Count != savedCount)
            {
                playerDB.newRandomList();
            }
        }
예제 #6
0
 private void listPlaylist_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     displayPlaylist       = playerDB.playlists[listPlaylist.SelectedIndex];
     listItems.ItemsSource = displayPlaylist.list;
     loadPlayitemMetadata();
 }