我只需要知道媒体播放器何时完成播放歌曲,如果有旗帜或什么......
Check code implementation of playstateChanged event Here
// Add a delegate for the PlayStateChange event.
player.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(player_PlayStateChange);
private void player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
// Test the current state of the player and display a message for each state.
switch (e.newState)
{
case 0: // Undefined
currentStateLabel.Text = "Undefined";
break;
case 1: // Stopped
currentStateLabel.Text = "Stopped";
break;
case 2: // Paused
currentStateLabel.Text = "Paused";
break;
case 3: // Playing
currentStateLabel.Text = "Playing";
break;
case 4: // ScanForward
currentStateLabel.Text = "ScanForward";
break;
case 5: // ScanReverse
currentStateLabel.Text = "ScanReverse";
break;
case 6: // Buffering
currentStateLabel.Text = "Buffering";
break;
case 7: // Waiting
currentStateLabel.Text = "Waiting";
break;
case 8: // MediaEnded
currentStateLabel.Text = "MediaEnded";
break;
case 9: // Transitioning
currentStateLabel.Text = "Transitioning";
break;
case 10: // Ready
currentStateLabel.Text = "Ready";
break;
case 11: // Reconnecting
currentStateLabel.Text = "Reconnecting";
break;
case 12: // Last
currentStateLabel.Text = "Last";
break;
default:
currentStateLabel.Text = ("Unknown State: " + e.newState.ToString());
break;
}
}
I think this gives an example in VB.net, maybe you can adapt it for your purpose: http://msdn.microsoft.com/en-us/library/dd562692(v=vs.85).aspx
EDIT: Just noticed there's ac# solution below the VB example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.