COM Exception HRESULT: 0xC00D1325 in C# winForm

0

I have a code in C# WinForm that should be able to read the list of songs from a listBox and then play each song with windowsMediaPlayer (for some reasons I want to play the songs from the last item of the listBox to the first one ) .

here is the code I'm using :

            int count = listBox1.Items.Count-1;
            listBox1.SelectedItem = listBox1.Items[count];
            axWindowsMediaPlayer1.URL = listBox1.SelectedItem.ToString();
            axWindowsMediaPlayer1.Ctlcontrols.play();

and then when playing the first song ended I wanted to change the url like this :

  private void axWindowsMediaPlayer1_PlayStateChange_1(object sender, _WMPOCXEvents_PlayStateChangeEvent e)
    {
        if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
        {

            if (count > 0)
            {
                count = count - 1;
                axWindowsMediaPlayer1.URL = listBox1.Items[count].ToString();
                axWindowsMediaPlayer1.Ctlcontrols.play();

            }
        }
    }

this code will play the first song . BUT at this line axWindowsMediaPlayer1.URL = listBox1.Items[count].ToString(); I got COM Exception ERROR and WindowsMediaPlayer control didn't play the other songs in the list .

here is the ERROR details :

   System.Runtime.InteropServices.COMException was unhandled by user code
   Message=Exception from HRESULT: 0xC00D1325
   Source=Interop.WMPLib
   ErrorCode=-1072884955
   StackTrace:
   at WMPLib.IWMPPlayer4.set_URL(String pbstrURL)
   at AxWMPLib.AxWindowsMediaPlayer.set_URL(String value)
   at Avaye_Malakooti_92.Form1.axWindowsMediaPlayer1_PlayStateChange_1(Object sender, _WMPOCXEvents_PlayStateChangeEvent e) in C:\Users\Novin Pendar\Documents\Visual Studio 2010\Projects\New folder\Avaye Malakooti 92\Avaye Malakooti 92\Form1.cs:line 459
   at AxWMPLib.AxWindowsMediaPlayer.RaiseOnPlayStateChange(Object sender, _WMPOCXEvents_PlayStateChangeEvent e)
   at AxWMPLib.AxWindowsMediaPlayerEventMulticaster.PlayStateChange(Int32 newState)
   InnerException: 

Here is the error

Anybody have any Idea why did I get that error or how should I solve it ? thanks for help .

c#
exception
media-player
comexception
hresult
asked on Stack Overflow Jul 24, 2013 by Bahareh LV

2 Answers

2

a simple google search for that HRESULT code specified this as the value:

0xC00D1325
NS_E_CURL_INVALIDCHAR
The URL contains one or more characters that are not valid.

So, it seems you aren't pointing your player at a valid url for the second song.

You can see a list of HRESULT codes here

answered on Stack Overflow Jul 24, 2013 by Mike Corcoran
0

I solved the problem of not playing the other songs , by adding a Timer to my code like this :

 private void axWindowsMediaPlayer1_PlayStateChange_1(object sender, _WMPOCXEvents_PlayStateChangeEvent e)
    {
        if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
        {
            if (count > 0)
            {
                count = count - 1;
                axWindowsMediaPlayer1.URL = listBox1.Items[count].ToString();
                timer2.Enabled = true;

            }
        }
    }

and then put this code to my Timer2_Tick event :

private void timer2_Tick(object sender, EventArgs e)
    {
        axWindowsMediaPlayer1.Ctlcontrols.play();
        timer2.Enabled = false;
    } 

Hope this solution helps everyone who had the same problem as mine .

answered on Stack Overflow Jul 24, 2013 by Bahareh LV

User contributions licensed under CC BY-SA 3.0