2012-10-12 41 views

回答

0

Simple MCI Player - CodeProject,稍微改動:

public int GetCurrentPosition() 
{ 
    String command = "status MediaFile position"; 
    error = mciSendString(command, returnData, 
          returnData.Capacity, IntPtr.Zero); 
    return error == 0 ? int.Parse(returnData.ToString()) : 0; 
} 

public int GetSongLenght() 
{ 
    if (IsPlaying()) 
    { 
     String command = "status MediaFile length"; 
     error = mciSendString(command, returnData, returnData.Capacity, IntPtr.Zero); 
     return error == 0 ? int.Parse(returnData.ToString()) : 0; 
    } 
    else 
     return 0; 
} 
+0

thx但我的問題在這裏是關於trackbar ...我不知道如何顯示它的軌道進度... – Arshtat

+0

@ user1740616調用'GetCurrentPosition'來獲取文件的當前位置,然後將跟蹤欄的值設置爲該值。 – CodeCaster

+0

eventhandler怎麼樣?我想我也需要這個? – Arshtat

0

在VB中我做了這個一個計時器滴答子裏面...易peasy真的...

REM音頻是mcisendstring啄 REM TotalLength是當前曲目的總秒數

Dim PlayPosition As Long = 0 

    PlayPosition = audio.SecondsPlayed 
    If PlayPosition > 0 And PlayPosition < TotalLength Then 
     TrackBar1.Value = (PlayPosition/TotalLength) * TotalLength 
    End If