用APlayer Control控件播放音乐(axPlayer)
添加控件。在.com里面。该控件有自己的方法。都很简单的应用。在vs里面看提示懂得英语就可以知道什么意思。现在在vs2008写了个很简单的例子。该控件不能播放视频。代码如下:(托管c++类)
String ^m;
int rate;
int vol;
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::Windows::Forms::DialogResult file;
file=this->openFileDialog1->ShowDialog();
if(file==System::Windows::Forms::DialogResult::OK)
{
m=this->openFileDialog1->FileName;
this->axPlayer1->Open(m);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
this->axPlayer1->Play();
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
this->axPlayer1->Pause();
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
this->axPlayer1->Stop();
}
private: System::Void trackBar1_Scroll(System::Object^ sender, System::EventArgs^ e) {
rate=this->trackBar1->Value;
this->axPlayer1->SetPlaySpeed(rate);
}
private: System::Void trackBar2_Scroll(System::Object^ sender, System::EventArgs^ e) {
vol=this->trackBar2->Value;
this->axPlayer1->SetVolume(vol);
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
添加界面及运行截图:另外加了个打开文件的对话框控件