C#里WindowsMediaPlayer控件的playstate属性怎么用
例:if(axWindowsMediaPlayer1.playState==1){…………}这么写为什么不行呢?网上说playState返回int型,是不是错的?...
例:if(axWindowsMediaPlayer1.playState==1)
{
…………
}
这么写为什么不行呢?网上说playState返回int型,是不是错的? 展开
{
…………
}
这么写为什么不行呢?网上说playState返回int型,是不是错的? 展开
2个回答
2009-12-06
展开全部
我是楼主,这么写就可以了,呵呵,当然要感谢楼上回答的
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;
}
}
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;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询