Click here to Skip to main content
14,207,108 members
Rate this:
Please Sign up or sign in to vote.
See more:
media player gera uma exerção quando abro para escolher o arquivo na playlist. oque acontece é o seguinte clico na playlist uma vez funciona quando seleciono o vídeo ou a musica mas na esquecia quando clico outra vez ele seleciona a musica ou o vídeo mas as que já estavam adicionadas não somem gerando assim uma exerção quando clico nas mesma.
esse é o código

Google Translate:
media player generates an exercise when I open it to choose the file in the playlist. what happens is the following I click on the playlist once it works when I select the video or the music but in the forgotten when I click again it selects the music or the video but the ones that were already added do not add up thus generating an exercise when I click on them.
this is the code

private void btnLoadFile_Click(object sender, EventArgs e)
           Startindex = 0;
           playnext = false;
           OpenFileDialog opnFileDlg = new OpenFileDialog();
           opnFileDlg.Multiselect = true;
           opnFileDlg.Filter = "(mp3,wav,mp4,mov,wmv,mpg,avi,3gp,flv)|*.mp3;*.wav;*.mp4;*.3gp;*.avi;*.mov;*.flv;*.wmv;*.mpg|all files|*.*";
           if (opnFileDlg.ShowDialog() == DialogResult.OK)
               FileName = opnFileDlg.SafeFileNames;
               FilePath = opnFileDlg.FileNames;
               for (int i = 0; i <= FileName.Length - 1; i++)

               Startindex = 0;

What I have tried:

eu resolvi esse erro de outra forma ao invés de adicionar listbox adicionei listview mas não sei da a sequencia no código para a playlist ir para frente ou para trás
Google Translate:
I solved this error otherwise instead of adding listbox I added listview but I do not know of the sequence in the code for the playlist go forward or backward

private void Btnplaylist_Click(object sender, EventArgs e)
          string userName = System.Environment.UserName;
          Stream myStream = null;
          OpenFileDialog ofd = new OpenFileDialog();
          ofd.InitialDirectory = @"C:\Users\" + userName + "\\Documents\\MyMusic";
          ofd.Filter = "(mp3,wav,mp4,mov,wmv,mpg,avi,3gp,flv)|*.mp3;*.wav;*.mp4;*.3gp;*.avi;*.mov;*.flv;*.wmv;*.mpg|all files|*.*";
          ofd.FilterIndex = 1;
          ofd.RestoreDirectory = false;
          ofd.Multiselect = true;

          if (ofd.ShowDialog() == DialogResult.OK)
                  if ((myStream = ofd.OpenFile()) != null)
                      using (myStream)
                          string[] paths = ofd.FileNames;
                          string[] files = ofd.SafeFileNames;
                          for (int i = 0; i < files.Length; i++)
                              string[] salvwItem = new string[2];
                              salvwItem[0] = files[i];
                              salvwItem[1] = paths[i];
                              ListViewItem lvi = new ListViewItem(salvwItem);



              catch (Exception)


Updated 5 days ago
Patrice T 5 days ago
This forum is in English !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190612.1 | Last Updated 10 Jun 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100