2017-04-03 2 views
-2

Window Media Player에서 노래의 길이와 시간에 대해 진행률 표시 줄에서 작업하고 있지만이 코드가 멈췄습니다. 이 코드는 Visual Basic 용이지만 Visual Studio 2015를 사용하고 있으며 "Dim As Integer"문이 작동하지 않습니다. 내 버전의 현재 버전과 일치하도록이 코드를 수정하려면 어떻게해야합니까?미디어 플레이어 컨트롤

정말 고마워요.

웨슬리

다음

은 코드 : C#에서

private void timer1_Tick(object sender, EventArgs e) 
    { 

     progressBar1.Increment(1); 

     Dim Length As Integer = axWindowsMediaPlayer1.currentMedia.duration 
     Dim Current As Integer = axWindowsMediaPlayer1.Ctlcontrols.currentPosition; 

     progressBar1.Value = Current 
     progressBar1.Maximum = Length 

     if progressBar1.Value = 100 then 
      progressBar1.Value = 0 
    } 

    private void progressBar1_Click(object sender, EventArgs e) 
    { 

    } 
+2

해당 태그 중 하나만 적용됩니다. 하나를 선택하고 문제가 무엇인지 더 잘 설명하십시오 (VS2015는 VB를 포함합니다) – Plutonix

+2

코드가 VB와 C#을 혼합합니다. 그것은 작동하지 않습니다. – BradleyDotNET

+1

그리고 * 성명서가 작동하지 않는다고 말하면 아무 것도 우리에게 말하지 않습니다. – DavidG

답변

0

코드가 있어야한다 : 당신이 필요합니다, 그래서

private void timer1_Tick(object sender, EventArgs e) 
{ 
    progressBar1.Increment(1); 

    //Both currentPosition and duration are doubles 
    int length = (int)axWindowsMediaPlayer1.currentMedia.duration; 
    int current = (int) axWindowsMediaPlayer1.Ctlcontrols.currentPosition; 

    progressBar1.Value = current; 
    progressBar1.Maximum = length; 

    if (progressBar1.Value == 100) 
      progressBar1.Value = 0 
} 

, 모두 currentPositionduration이 두 배입니다 고려 그들을 캐스팅하거나 int로 구문 분석하십시오.

+0

안녕하세요, Mo 론지! 대답 해줘서 고마워! 모든 것이 이제는 좋지만 나에게 약간의 문제가 있습니다. 어떻게 캐스팅 할 수 있습니까? 보여 주시겠습니까? 미안해, 나는 아주 새로운 사람이야. : – Wesley

+0

내가 anwser 또는 Convert.ToInt32 (axWindowsMediaPlayer1.currentMedia.duration)에서했던 것처럼'(int) '을 넣음으로써 – moondaisy

+0

오 마이 갓! 이제 작동합니다. – Wesley