一、添加媒体操作变量:
CWMPPlayer40 mPlayer4;//插件变量
CWMPSettings mSet; //setting变量
CWMPControls mmCtrl;// Controls变量
CWMPPlaylist mlist; //list变量
CWMPMedia mMedia;//媒体文件变量
二、OnInitDialog()
mPlayer4.put_URL(_T("F:\\CloudMusic\\刘珂矣 - 如是.mp3"));
mmCtrl = static_cast<CWMPControls>(mPlayer4.get_controls());//成员变量初始化
mSet = static_cast<CWMPSettings>(mPlayer4.get_settings());
mlist = static_cast<CWMPPlaylist>(mPlayer4.get_currentPlaylist());
mPlayer4.put_currentPlaylist(mlist); //不必须,设置播放列表
mSet.put_autoStart(TRUE);//自动播放
mSet.setMode(_T("loop"),TRUE);//单曲循环
----------------------------------------------------------------------------------------------------------------
CFileDialog file(TRUE,_T(""),_T(""),
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("(*.*)|*.*|(*.mp3)|*.mp3|(*.avi)|*.avi"));
if (file.DoModal())
{
mPlayer4.put_URL(file.GetPathName());
SetDlgItemText(IDC_BUTTON4,mPlayer4.get_URL());
mMedia = static_cast<CWMPMedia>(mPlayer4.newMedia(file.GetPathName()));
mlist.appendItem(mMedia);
mPlayer4.put_currentPlaylist(mlist);
CString info;
long mCount = mMedia.get_attributeCount();
for (long i = 0;i<mCount;i++)
{
info.Format(_T("%s:%s\n\n"),mMedia.getAttributeName(i),mMedia.getItemInfo(mMedia.getAttributeName(i)));
MessageBox(info);
}
TRACE("\n\n\n\n");
}
-------------------------------------------------------------------------------
void CSqlAdoDlg::OnBnClickedButton7()
{
// TODO: Add your control notification handler code here
CString str;
GetDlgItemText(IDC_BUTTON7,str);
if (str==_T("暂停"))
{
mmCtrl.pause();
SetDlgItemText(IDC_BUTTON7,_T("继续"));
}else{
mmCtrl.play();
SetDlgItemText(IDC_BUTTON7,_T("暂停"));
}
}