Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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);

                        }
                    }
                }

            }
        }