播放媒体后,按停止键(WindowsMediaPlayer),再将鼠标移至菜单栏(没有点击),立刻又继续播放
以下是部分代码:
BOOL CPLAYERDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
skinppLoadSkin(_T("blue.ssk"));//blue.ssk为项目下的皮肤文件,
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
m_control=static_cast<CWMPControls>(m_play.GetControls());
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CPLAYERDlg::OnPlay()
{
// TODO: Add your control notification handler code here
CON=1;
CString str;
if(m_list.GetCount()<=0)MessageBox("请先打开最少一个媒体文件!","Warning",MB_OK);
else
{
KillTimer(1);
if(m_list.GetCurSel()<0)
{
m_list.SetCurSel(0);
}
index=m_list.GetCurSel();
m_list.GetText(index,str);
m_play.SetUrl(str);
SetTimer(1,1000,NULL);
}
}
void CPLAYERDlg::OnBnClickedSequence()
{
// TODO: 在此添加控件通知处理程序代码
FG=0;
}
void CPLAYERDlg::OnBnClickedRandom()
{
// TODO: 在此添加控件通知处理程序代码
FG=1;
}
void CPLAYERDlg::OnBnClickedCycle()
{
// TODO: 在此添加控件通知处理程序代码
FG=2;
}
void CPLAYERDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
int index1=m_play.GetPlayState();
if(index1==1)
{
if(FG==0)
{
CString str;
int index=m_list.GetCurSel()+1;
if(index>=m_list.GetCount())
index=0;
m_list.GetText(index,str);
m_play.SetUrl(str);
m_list.SetCurSel(index);
}
else if(FG==1)
{
srand(time(0));
m_list.SetCurSel(rand()%m_list.GetCount());
m_list.GetText(m_list.GetCurSel(),m_pathname);
m_play.SetUrl(m_pathname);
}
else if(FG==2)
{
m_list.GetText(m_list.GetCurSel(),m_pathname);
m_play.SetUrl(m_pathname);
}
else;
}
CDialog::OnTimer(nIDEvent);
}