Beispiel #1
0
 private async void BrowsePlaylist()
 {
     using (OpenFileDialog selectFileDialog = new OpenFileDialog())
     {
         selectFileDialog.Filter = "Playlist Files|*.xspf;*.asx;*.wax;*.wvx;*.b4s;*.m3u;*.m3u8;*.pls;*.smil;*.smi;*.zpl;";
         {
             if (selectFileDialog.ShowDialog() == DialogResult.OK)
             {
                 IPlaylistIO theReader = PlaylistIOFactory.GetInstance().GetPlaylistIO(selectFileDialog.FileName);
                 try
                 {
                     if (AddTrackCheckBox.Checked)
                     {
                         DatabaseHandler.ImportSong(theReader.FilePaths);
                     }
                     foreach (string s in theReader.FilePaths)
                     {
                         PlayerForm.AddQueue(s);
                     }
                     LibraryNeedsUpdating = true;
                     PlayerForm.PlayMusic();
                     await UpdateLibrary();
                 }
                 catch (DirectoryNotFoundException)
                 {
                     MessageBox.Show("This playlist file cannot be played because one or more of the songs could not be found.", "Songs not found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     PlayerForm.ClearQueue();
                 }
             }
         }
     }
 }
 private void progressTimer_Tick(object sender, EventArgs e)
 {
     if (PlayerForm.playing & !PlayerForm.paused)
     {
         progressIndicator.Text = PlayerForm.getSongPosition();
     }
 }
        public void PopulateList()
        {
            var list       = PlayerForm.GetQueue();
            var nextlength = 0;
            int number     = 1;

            foreach (var song in list)
            {
                string place;
                if (PlayerForm.QueuePosition == number)
                {
                    place = "NOW PLAYING: ";
                }
                else if (PlayerForm.QueuePosition == number - 1)
                {
                    place = "UP NEXT: ";
                }
                else
                {
                    place = (number - PlayerForm.QueuePosition).ToString();
                }
                Track theTrack = new Track(song);
                listBox1.Items.Add($"{place} {theTrack.Artist} - {theTrack.Title}");
                if (PlayerForm.QueuePosition < number)
                {
                    nextlength += theTrack.Duration;
                }
                number++;
            }
            label2.Text = $"Remaining Time - {Format(nextlength)}";
        }
Beispiel #4
0
        private async void UserInterface_DragDrop(object sender, DragEventArgs e)
        {
            if (!TaskIsRunning)
            {
                await Task.Run(() =>
                {
                    TaskIsRunning = true;

                    string[] tracks = (string[])e.Data.GetData(DataFormats.FileDrop);
                    PlayerForm.AddQueue(tracks);

                    if (AddTrackCheckBox.Checked && (e.KeyState & 8) != 8 /*CTRL key*/)
                    {
                        DatabaseHandler.ImportSong(tracks);
                    }
                });

                TaskIsRunning        = false;
                LibraryNeedsUpdating = true;
                if ((e.KeyState & 4) != 4 /*SHIFT key*/)
                {
                    PlayerForm.PlayMusic();
                }
                await UpdateLibrary();
            }
        }
Beispiel #5
0
 private void ProgressBar_Scroll(object sender, EventArgs e)
 {
     if (PlayerForm.playing)
     {
         PlayerForm.RepositionMusic(ProgressBar.Value);
     }
 }
        private void addPlaylist_Click(object sender, EventArgs e)
        {
            OpenFileDialog selectFileDialog = new OpenFileDialog();

            selectFileDialog.Filter = "Playlist Files|*.xspf;*.asx;*.wax;*.wvx;*.b4s;*.m3u;*.m3u8;*.pls;*.smil;*.smi;*.zpl;";
            {
                if (selectFileDialog.ShowDialog() == DialogResult.OK)
                {
                    IPlaylistIO theReader = PlaylistIOFactory.GetInstance().GetPlaylistIO(selectFileDialog.FileName);
                    try
                    {
                        foreach (string s in theReader.FilePaths)
                        {
                            PlayerForm.AddQueue(s);
                        }
                        listBox1.Items.Clear();
                        PopulateList();
                    }
                    catch (System.IO.DirectoryNotFoundException)
                    {
                        MessageBox.Show("This playlist file cannot be played because one or more of the songs could not be found.", "Songs not found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        PlayerForm.ClearQueue();
                    }
                }
            }
        }
Beispiel #7
0
        private void songExceptionHandler(object sender, PlaybackExceptionEventArgs e)
        {
            Notification notification = new Notification("An error occured.", $"{e.Details}\nWe'll skip to the next track for you.", 2500);

            notification.Location = Location;
            notification.Show();
            PlayerForm.NextSong();
        }
Beispiel #8
0
 private void LibraryQueueButton(ListBox listBox, List <string> list)
 {
     foreach (int selectedItem in listBox.SelectedIndices)
     {
         PlayerForm.AddQueue(list[selectedItem]);
     }
     listBox.ClearSelected();
 }
Beispiel #9
0
 private void volumeBar_Scroll(object sender, EventArgs e)
 {
     PlayerForm.currentvolume = (float)volumeBar.Value / 100.0f;
     if (PlayerForm.playing)
     {
         PlayerForm.UpdateSettings();
     }
     VolumeTimer = 100;
 }
Beispiel #10
0
 private void progressTimer_Tick(object sender, EventArgs e)
 {
     if (PlayerForm.playing & !PlayerForm.paused)
     {
         PlayerForm.avoidnextqueue = false;
         progressIndicator.Text    = PlayerForm.getSongPosition();
         if ((int)PlayerForm.Player.CurrentBackend.CurrentTime.TotalSeconds <= ProgressBar.Maximum)
         {
             ProgressBar.Value = (int)PlayerForm.Player.CurrentBackend.CurrentTime.TotalSeconds;
         }
     }
 }
Beispiel #11
0
 private void Form1_FormClosing(Object sender, FormClosingEventArgs e)
 {
     Properties.Settings.Default.General_Volume     = PlayerForm.currentvolume;
     Properties.Settings.Default.General_LastUpdate = PlayerForm.lastUpdateCheck;
     Properties.Settings.Default.Save();
     if (Properties.Settings.Default.General_DiscordIntegration)
     {
         PlayerForm.DisposeRPC();
     }
     //Application.Exit();
     Task.Run(PlayerForm.ShutdownTheApp);
 }
Beispiel #12
0
 private void songChangedHandler(object sender, EventArgs e)
 {
     progressTimer.Enabled = true;
     ATL.Track metadata = new ATL.Track(PlayerForm.filePath);
     titleLabel.Text = $"{metadata.Artist} - {metadata.Title}";
     Text            = $"{metadata.Artist} - {metadata.Title} | FRESHMusicPlayer";
     getAlbumArt();
     ProgressBar.Maximum = (int)PlayerForm.Player.CurrentBackend.TotalTime.TotalSeconds;
     if (Properties.Settings.Default.General_DiscordIntegration)
     {
         PlayerForm.UpdateRPC("play", metadata.Artist, metadata.Title);
     }
 }
        private void addSong_Click(object sender, EventArgs e)
        {
            using (var selectFileDialog = new OpenFileDialog())

            {
                if (selectFileDialog.ShowDialog() == DialogResult.OK)
                {
                    PlayerForm.AddQueue(selectFileDialog.FileName);
                    listBox1.Items.Clear();
                    PopulateList();
                }
            }
        }
 private void pauseplayButton_Click(object sender, EventArgs e)
 {
     if (!PlayerForm.paused)
     {
         pauseplayButton.Image = Properties.Resources.baseline_play_arrow_black_18dp;
         PlayerForm.PauseMusic();
     }
     else
     {
         pauseplayButton.Image = Properties.Resources.baseline_pause_black_18dp;
         PlayerForm.ResumeMusic();
     }
 }
Beispiel #15
0
 private void PlayButton()
 {
     if (!PlayerForm.paused)
     {
         pauseplayButton.Image = Properties.Resources.baseline_play_arrow_black_18dp;
         PlayerForm.PauseMusic();
     }
     else
     {
         pauseplayButton.Image = Properties.Resources.baseline_pause_black_18dp;
         PlayerForm.ResumeMusic();
     }
 }
Beispiel #16
0
 private async void BrowseMusic()
 {
     using (var selectFileDialog = new OpenFileDialog())
     {
         selectFileDialog.Filter = "Audio Files|*.wav;*.aiff;*.mp3;*.wma;*.3g2;*.3gp;*.3gp2;*.3gpp;*.asf;*.wmv;*.aac;*.adts;*.avi;*.m4a;*.m4a;*.m4v;*.mov;*.mp4;*.sami;*.smi;*.flac|Other|*";
         if (selectFileDialog.ShowDialog() == DialogResult.OK)
         {
             PlayerForm.AddQueue(selectFileDialog.FileName);
             PlayerForm.PlayMusic();
             if (AddTrackCheckBox.Checked)
             {
                 DatabaseHandler.ImportSong(selectFileDialog.FileNames);
             }
             LibraryNeedsUpdating = true;
             await UpdateLibrary();
         }
     }
 }
Beispiel #17
0
 public void ApplySettings()
 {
     if (Properties.Settings.Default.Appearance_DarkMode)
     {
         ThemeHandler.SetColors(this,
                                (44, 47, 51),
                                (255, 255, 255),
                                Color.Black,
                                Color.White);
     }
     else
     {
         ThemeHandler.SetColors(this, (Properties.Settings.Default.Appearance_AccentColorRed, Properties.Settings.Default.Appearance_AccentColorGreen, Properties.Settings.Default.Appearance_AccentColorBlue), (255, 255, 255), Color.White, Color.Black);
     }
     if (Properties.Settings.Default.General_DiscordIntegration)
     {
         PlayerForm.InitDiscordRPC();
     }
     else
     {
         PlayerForm.DisposeRPC();
     }
 }
 private void stopButton_Click(object sender, EventArgs e)
 {
     PlayerForm.ClearQueue();
     PlayerForm.StopMusic();
 }
Beispiel #19
0
 private static void StopButton()
 {
     PlayerForm.ClearQueue();
     PlayerForm.StopMusic();
 }
 private void clearQueue_Click(object sender, EventArgs e)
 {
     PlayerForm.ClearQueue();
     listBox1.Items.Clear();
     PopulateList();
 }
 private void toolStripMenuItem1_Click(object sender, EventArgs e)
 {
     PlayerForm.QueuePosition = listBox1.SelectedIndex;
     PlayerForm.PlayMusic();
 }
 private void previous_Click(object sender, EventArgs e)
 {
     PlayerForm.PreviousSong();
     listBox1.Items.Clear();
     PopulateList();
 }
 private void next_Click(object sender, EventArgs e)
 {
     PlayerForm.NextSong();
     listBox1.Items.Clear();
     PopulateList();
 }
Beispiel #24
0
 private void previousTrackToolStripMenuItem_Click(object sender, EventArgs e) => PlayerForm.PreviousSong();
Beispiel #25
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (!searchBox.Focused && Properties.Settings.Default.General_KeyboardNavigation)
            {
                switch (keyData)        // TODO: In the future, I wanna make these keys rebindable
                {
                case Keys.A:            // Tab controls
                    tabControl2.SelectTab(songTab);
                    return(true);

                case Keys.S:
                    tabControl2.SelectTab(artistTab);
                    return(true);

                case Keys.D:
                    tabControl2.SelectTab(albumTab);
                    return(true);

                case Keys.F:
                    tabControl2.SelectTab(searchTab);
                    return(true);

                case Keys.G:
                    tabControl2.SelectTab(importTab);
                    return(true);

                case Keys.Q:
                    tabControl1.SelectTab(tabPage3);
                    return(true);

                case Keys.MediaPlayPause:                   // Playback controls
                case Keys.C:
                    PlayButton();
                    return(true);

                case Keys.V:
                case Keys.MediaNextTrack:
                    PlayerForm.NextSong();
                    return(true);

                case Keys.X:
                case Keys.MediaStop:
                    StopButton();
                    return(true);

                case Keys.P:
                    TagEditor tagEditor = new TagEditor(new List <string> {
                        PlayerForm.filePath
                    });
                    tagEditor.Show();
                    return(true);

                case Keys.O:

                    return(true);

                default:
                    break;
                }
            }
            return(base.ProcessCmdKey(ref msg, keyData));
        }
 private void nextButton_Click(object sender, EventArgs e)
 {
     PlayerForm.NextSong();
 }