2013-10-29 5 views
1

나는 listBox에서 자동으로 다음 노래로 이동하여 재생해야하지만 재생되지는 않습니다. 나는 다음 곡으로 넘어가지만, 그것이 변하면 연주를 시작하지 않는다. 코드 조각은 다음과 같습니다.C# Media Player (WMP) 자동 다음 노래

if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded) 
{ 
    if (listBox1.SelectedIndex != listBox1.Items.Count - 1) 
    { 
     listBox1.SelectedIndex = listBox1.SelectedIndex + 1; 
    } 
} 

"다음"및 "이전"단추에 대해 동일한 방법을 사용하며 완벽하게 작동합니다.

나는 또한이 시도 :

if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded) 
{ 
    listBox1.SelectedIndex = listBox1.SelectedIndex + 1; 
    axWindowsMediaPlayer1.Ctlcontrols.play(); 
} 

그것은 다음 곡으로 이동하지만, 이전에 언급 한 바와 같이, 단지 재생되지 않습니다.

어떻게 재생할 수 있습니까?

+0

나는 문제를 해결했다. – jermy9999

+2

어떻게 그것을 해결할 수 jermy, 나는 똑같은 문제에 직면 해있다. – QViet

답변

1

당신은 PlayStateChange 이벤트 처리기를 사용할 수 있습니다

private void WindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) 
    { 
if (e.newState == 1) 
     { 
      if (listBox1.SelectedIndex != listBox1.Items.Count - 1) 
      { 
       BeginInvoke(new Action(() => { 
        listBox1.SelectedIndex = listBox1.SelectedIndex + 1 
       })); 
      } 
     } 
    }