wince c#实现 视频播放控制
各位大侠,我想在WINCE平台上实现一个视频的播放界面,并且可以通过程序控制播放和暂停,请问有哪位有这方面的高见??
[解决办法]
首先你要添加axWindowsMediaPlayer控件,
你可以右击”工具箱“->添加项...找到COM组件里面的
Windows Media Player添加就OK了
private void tr_start_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"f:\kugou\a.mp3";
axWindowsMediaPlayer1.Ctlcontrols.play();
}
int i = 1;
private void tr_pause_Click(object sender, EventArgs e)
{
if (i == 1)
{
axWindowsMediaPlayer1.Ctlcontrols.pause();
tr_pause.Text = "继续";
i = 0;
}
else
{
axWindowsMediaPlayer1.Ctlcontrols.play();
tr_pause.Text = "暂停";
i = 1;
}
}
private void tr_stop_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
}
if (fd == DialogResult.Cancel)
{
return;
}
else
{
listBox1.Items.Add(ofd.FileNames[0]);
DataSet ds = new DataSet();
}
}
private void Form1_Load(object sender, EventArgs e)
{
axWindowsMediaPlayer1.windowlessVideo = false;
axWindowsMediaPlayer1.Ctlcontrols.stop(); //停止
axWindowsMediaPlayer1.Ctlcontrols.pause(); //暂停
axWindowsMediaPlayer1.settings.autoStart = true; //自动播放
axWindowsMediaPlayer1.settings.mute = false; //静音
axWindowsMediaPlayer1.settings.volume = 100; // 音量 int 0 ~ 100 100 是最大音量
axWindowsMediaPlayer1.Ctlcontrols.currentPosition = 30; //当前的播放位置 double
}
private void 播放ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 0)
{
axWindowsMediaPlayer1.Ctlcontrols.play(); //播放
axWindowsMediaPlayer1.URL = listBox1.Items[0].ToString();
axWindowsMediaPlayer1.currentMedia.duration.ToString();//影片长度
axWindowsMediaPlayer1.currentMedia.getItemInfo("Title");//标题
axWindowsMediaPlayer1.currentMedia.getItemInfo("Author");//作者
}
else
{
MessageBox.Show("请添加文件");
}
}
}
}