Exemplo n.º 1
0
        protected override void loadNextSong(object sender, StoppedEventArgs e)
        {
            Debug.WriteLine("Load next song");
            if (manuallyStopped) {  // this prevents next song from loading when stop button is pressed
                Debug.WriteLine("Manual stop");
                manuallyStopped = false;
                return;
            }

            nextSong = getNextSong();

            if (samplePlayer.ready())
                samplePlayer.playSample();
            else
                playSong();
        }
Exemplo n.º 2
0
        public void initialize(Song song)
        {
            if (song.usingTagLib) {

                metaFile = song.tagFile;

                this.Text = song.ToString();
                textBox_Title.Text = metaFile.Tag.Title;
                textBox_Artist.Text = metaFile.Tag.FirstPerformer;
                if (metaFile.Tag.Genres.Length > 0)
                    textBox_Genre.Text = metaFile.Tag.Genres[0];
                foreach (String genre in metaFile.Tag.Genres)
                    textBox_Genre.Text += "; " + genre;
                textBox_Album.Text = metaFile.Tag.Album;
                textBox_Year.Text = "" + metaFile.Tag.Year;
                textBox_Comments.Text = metaFile.Tag.Comment;

                button_SaveChanges.Enabled = true;

            } else if (song.usingId3Tag && !song.fileCorrupted) {

                id3Tag = song.id3Tag;

                this.Text = song.ToString();
                textBox_Title.Text = id3Tag.Title.Value;
                textBox_Artist.Text = id3Tag.Artists.Value;
                textBox_Genre.Text = id3Tag.Genre.Value;
                textBox_Album.Text = id3Tag.Album.Value;
                textBox_Year.Text = "" + id3Tag.Year.Value;
                foreach (CommentFrame comment in id3Tag.Comments)
                    textBox_Comments.Text += comment.Comment + "\n";

                button_SaveChanges.Enabled = true;

            } else {
                //initialized = false;

                textBox_Title.Text = null;
                textBox_Artist.Text = null;
                textBox_Genre.Text = null;
                textBox_Album.Text = null;
                textBox_Year.Text = null;
                textBox_Comments.Text = null;

                button_SaveChanges.Enabled = false;
            }
        }
Exemplo n.º 3
0
        private void loadMP3Dialog_FileOk(Object sender, CancelEventArgs e)
        {
            //List<Song> songs = new List<Song>();

            foreach (String file in loadMP3Dialog.FileNames) {

                String fileType = file.Substring(file.LastIndexOf(".") + 1);
                if (fileType.ToLower() == "mp3") {
                    Song song = new Song();
                    if (song.initialize(file))
                        sampleList.Items.Add(song);
                    else
                        MessageBox.Show(file + " does not appear to be a valid mp3 file");

                } else if (fileType == "m3u") {

                    StreamReader m3u;
                    try {
                        m3u = File.OpenText(file);

                        String line;
                        while ((line = m3u.ReadLine()) != null) {

                            if (line.StartsWith("#EXTINF:")) {

                                String filepath = m3u.ReadLine();
                                if (filepath.Substring(1, 1) != ":") {
                                    filepath = file.Substring(0, file.LastIndexOf("\\") + 1) + filepath;
                                }

                                Song song = new Song();
                                if (song.initialize(filepath)) {
                                    sampleList.Items.Add(song);
                                } else
                                    MessageBox.Show(filepath + " does not appear to be a valid mp3 file");

                            }
                        }
                    } catch (Exception ex) {
                        MessageBox.Show(ex.Message);
                        return;
                    }

                }
            }

            //sampleList.Items.AddRange(songs.ToArray());
            getNextSample();
        }
Exemplo n.º 4
0
 private void label_SongTitle_DoubleClick(Object sender, EventArgs e)
 {
     songRightClicked = currentSong;
     editID3Tag(sender, e);
 }
Exemplo n.º 5
0
 private void songList_MouseDoubleClick(Object sender, MouseEventArgs e)
 {
     songRightClicked = (Song)listBox_SearchResults.SelectedItem;
     editID3Tag(sender, e);
 }
Exemplo n.º 6
0
        private void mouseClickListBox(Object sender, MouseEventArgs e)
        {
            int index = listBox_SearchResults.IndexFromPoint(e.Location);

            if (index <= -1)
                return;

            if (e.Button == MouseButtons.Right) {
                songRightClicked = (Song)listBox_SearchResults.Items[index];
            }
            //Debug.WriteLine(index);
            //Debug.WriteLine(songRightClicked);
        }
Exemplo n.º 7
0
        private void getResults(List<String> allFiles)
        {
            foreach (String file in allFiles) {

                Song song = new Song();
                if (song.initialize(file) && song.matchesAll(keyword)) {

                    addToListBox(song);
                    if (cancelSearch) {
                        cancelSearch = false;
                        return;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void editID3Tag(Object sender, EventArgs e)
        {
            if (songRightClicked != null) {
                if (editForm == null)
                    editForm = new MetaDataEditForm();
                editForm.initialize(songRightClicked);
                editForm.Show();

                songRightClicked = null;
            }
        }
Exemplo n.º 9
0
 private void addToListBox(Song song)
 {
     if (listBox_SearchResults.InvokeRequired) {
         listBox_SearchResults.Invoke(new SetListCallback(addToListBox), new object[] { song });
     } else {
         listBox_SearchResults.Items.Add(song);
         this.Size = fullSize;
     }
 }
Exemplo n.º 10
0
        private void removeFromListToolStripMenuItem_Click(Object sender, EventArgs e)
        {
            songList.Items.Remove(songRightClicked);

            if (songRightClicked == currentSong)
                --nextSongIndex;

            songRightClicked = null;
        }
Exemplo n.º 11
0
        private void mouseClickListBox(Object sender, MouseEventArgs e)
        {
            int index = songList.IndexFromPoint(e.Location);

            if (index <= -1)
                return;

            songList.SelectedIndex = index;
            if (e.Button == MouseButtons.Right)
                songRightClicked = (Song)songList.Items[index];
            else if (e.Button == MouseButtons.Left) {

                Label label = new Label();
                label.Location = e.Location;
                label.Text = "Test";

            }
            //Debug.WriteLine(index);
            //Debug.WriteLine(songRightClicked);
        }
Exemplo n.º 12
0
        private void loadMp3Files(String[] files)
        {
            foreach (string file in files) {
                String fileType = file.Substring(file.LastIndexOf(".") + 1);
                if (fileType.ToLower() == "mp3") {

                    Song song = new Song();
                    if (!song.initialize(file))
                        MessageBox.Show(" Could not read ID3 metadata in " + file);
                    songList.Items.Add(song);

                } else if (fileType == "m3u") {

                    StreamReader m3u = File.OpenText(file);
                    String line;
                    while ((line = m3u.ReadLine()) != null) {

                        if (line.StartsWith("#EXTINF:")) {

                            String filepath = m3u.ReadLine();
                            if (filepath.Substring(1, 1) != ":") {
                                filepath = file.Substring(0, file.LastIndexOf("\\") + 1) + filepath;
                            }

                            Song song = new Song();
                            if (!song.initialize(filepath))
                                MessageBox.Show("Could not read ID3 metadata in " + filepath);
                            songList.Items.Add(song);

                        }
                    }
                }

            }
        }
Exemplo n.º 13
0
 private void label_SongTitle_DoubleClick(Object sender, EventArgs e)
 {
     songRightClicked = currentSong;
     editID3Tag(sender, e);
 }