|
|
@@ -0,0 +1,573 @@
|
|
|
+// CPlayerDlg.cpp : 实现文件
|
|
|
+//
|
|
|
+
|
|
|
+#include "stdafx.h"
|
|
|
+#include "CPlayerDlg.h"
|
|
|
+#include "afxdialogex.h"
|
|
|
+
|
|
|
+#define FULLSCREEN_TIMERID 8
|
|
|
+#define INTERVAL_TIMERID 9
|
|
|
+#define WNDTOPMOST_TIMERID 10
|
|
|
+
|
|
|
+// CPlayerDlg 对话框
|
|
|
+
|
|
|
+IMPLEMENT_DYNAMIC(CPlayerDlg, CDialogEx)
|
|
|
+
|
|
|
+BEGIN_EVENTSINK_MAP(CPlayerDlg, CDialogEx)
|
|
|
+ ON_EVENT(CPlayerDlg, IDC_OCX1, 5101, CPlayerDlg::PlayStateChangeOcx1, VTS_I4)
|
|
|
+END_EVENTSINK_MAP()
|
|
|
+
|
|
|
+// 默认构造函数
|
|
|
+CPlayerDlg::CPlayerDlg(player_callback_t*pCallback, CWnd* pParent /*=NULL*/)
|
|
|
+ : CDialogEx(CPlayerDlg::IDD, pParent), m_player(NULL), m_bMax(false), m_bInit(false),
|
|
|
+ m_bTimer(false), m_hMonitor(NULL), m_nPlayCnt(0), m_nMediaInx(0), m_pConfig(NULL)
|
|
|
+{
|
|
|
+ m_hIcon = AfxGetApp()->LoadIcon(IDI_PLAYER);
|
|
|
+ memcpy(&m_callback, pCallback, sizeof(player_callback_t));
|
|
|
+}
|
|
|
+
|
|
|
+// 音视频播放
|
|
|
+CPlayerDlg::CPlayerDlg(CWmpPlayConfig *pConfig, player_callback_t*pCallback, CWnd *pParent/* = NULL*/)
|
|
|
+ : CDialogEx(CPlayerDlg::IDD, pParent), m_player(NULL), m_bMax(false), m_bInit(false),
|
|
|
+ m_bTimer(false), m_hMonitor(NULL), m_nPlayCnt(0), m_nMediaInx(0)
|
|
|
+{
|
|
|
+ m_hIcon = AfxGetApp()->LoadIcon(IDI_PLAYER);
|
|
|
+ m_pConfig = pConfig;
|
|
|
+ memcpy(&m_callback, pCallback, sizeof(player_callback_t));
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+CPlayerDlg::~CPlayerDlg()
|
|
|
+{
|
|
|
+ if (m_player != NULL)
|
|
|
+ {
|
|
|
+ delete m_player;
|
|
|
+ m_player = NULL;
|
|
|
+ }
|
|
|
+ m_pConfig = NULL;
|
|
|
+}
|
|
|
+
|
|
|
+BOOL CPlayerDlg::OnInitDialog()
|
|
|
+{
|
|
|
+ CDialogEx::OnInitDialog();
|
|
|
+
|
|
|
+ SetIcon(m_hIcon, TRUE); // 设置大图标
|
|
|
+ SetIcon(m_hIcon, FALSE); // 设置小图标
|
|
|
+
|
|
|
+ long ScreenWidth = GetSystemMetrics(SM_CXSCREEN); //主屏幕宽度
|
|
|
+ long ScreenHeight = GetSystemMetrics(SM_CYSCREEN); //主屏幕高度
|
|
|
+
|
|
|
+ if (LOCALAUDIO != m_pConfig->eMode) {
|
|
|
+ PlayerLog(PLAYER_LOG_DEBUG, "ScreenWidth = %u, ScreenHeight= %u, m_pConfig->nWndX = %d, m_pConfig->nWndY = %d.", ScreenWidth, ScreenHeight, m_pConfig->nWndX, m_pConfig->nWndY);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (SALESNOTICE == m_pConfig->eMode){
|
|
|
+ if (m_pConfig->nWndX >= ScreenWidth || m_pConfig->nWndY >= ScreenHeight){
|
|
|
+ m_pConfig->bPrimMonitor = false;
|
|
|
+ m_pConfig->nWndX -= ScreenWidth;
|
|
|
+ if (m_pConfig->nWndX < 0){
|
|
|
+ m_pConfig->nWndX = 0;
|
|
|
+ }
|
|
|
+ m_pConfig->nWndY -= ScreenHeight;
|
|
|
+ if (m_pConfig->nWndY < 0){
|
|
|
+ m_pConfig->nWndY = 0;
|
|
|
+ }
|
|
|
+ PlayerLog(PLAYER_LOG_DEBUG, "bPrimMonitor flag is %s, m_pConfig->nWndX = %d, m_pConfig->nWndY = %d.", m_pConfig->bPrimMonitor? "true":"false", m_pConfig->nWndX, m_pConfig->nWndY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MONITORINFOEX mix;
|
|
|
+ mix.cbSize = sizeof(mix);
|
|
|
+ if (m_pConfig->bPrimMonitor == true) // 默认情况,在主屏显示
|
|
|
+ {
|
|
|
+ m_hMonitor = MonitorFromWindow(this->GetSafeHwnd(), MONITOR_DEFAULTTONULL);
|
|
|
+ GetMonitorInfo(m_hMonitor, (LPMONITORINFO)&mix);
|
|
|
+ SetRect(&m_monitorRect, mix.rcMonitor.left, mix.rcMonitor.top, mix.rcMonitor.right, mix.rcMonitor.bottom);
|
|
|
+ }
|
|
|
+ else // 在副屏显示
|
|
|
+ {
|
|
|
+ POINT pt;
|
|
|
+ pt.x = ScreenWidth+5;
|
|
|
+ pt.y = 5;
|
|
|
+ m_hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL); //尝试获取副屏的句柄
|
|
|
+ if (m_hMonitor != NULL)
|
|
|
+ {
|
|
|
+ GetMonitorInfo(m_hMonitor, (LPMONITORINFO)&mix);
|
|
|
+ SetRect(&m_monitorRect, mix.rcMonitor.left, mix.rcMonitor.top, mix.rcMonitor.right, mix.rcMonitor.bottom);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OnCancel();
|
|
|
+ SetEvent(m_pConfig->h_WMPCreateEvent);
|
|
|
+ SetEvent(m_pConfig->h_WMPPlayEndEvent);
|
|
|
+ PlayerLogEvent(PLAYER_VICE_LOCATION_ERROR, "vice monitor setting error!");
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CRect Rect;
|
|
|
+ this->GetClientRect(&Rect);
|
|
|
+ m_player = new CWMPPlayer4;
|
|
|
+ BOOL bCreateRet = m_player->Create(_T("SalesVideo"),WS_CHILD|WS_VISIBLE,Rect,this,IDC_OCX1);
|
|
|
+ if (bCreateRet == FALSE)
|
|
|
+ {
|
|
|
+ OnCancel();
|
|
|
+ SetEvent(m_pConfig->h_WMPCreateEvent); // 发出窗口创建完成事件
|
|
|
+ SetEvent(m_pConfig->h_WMPPlayEndEvent);
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ SetEvent(m_pConfig->h_WMPCreateEvent); // 发出窗口创建完成事件
|
|
|
+
|
|
|
+ m_bInit = true;
|
|
|
+
|
|
|
+ ::SetWindowPos(m_player->GetSafeHwnd(),HWND_TOP,m_monitorRect.left,m_monitorRect.top,0,0,SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+ m_player->put_enableContextMenu(FALSE);
|
|
|
+ m_player->put_stretchToFit(TRUE);
|
|
|
+ m_player->put_fullScreen(FALSE);//禁止全屏
|
|
|
+
|
|
|
+ if (_stricmp(m_pConfig->strRootPath, ""))
|
|
|
+ {
|
|
|
+ if(m_pConfig->eMode == SINGLE) // 单一模式播放
|
|
|
+ {
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(),HWND_TOP,m_monitorRect.left,m_monitorRect.top,0,0,SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+ m_player->put_URL(m_pConfig->strRootPath);
|
|
|
+ }
|
|
|
+ else if (m_pConfig->eMode == SALESRECORD || m_pConfig->eMode == THRIDSALESRECORD) // 客户经理录像模式播放
|
|
|
+ {
|
|
|
+ if (SALESRECORD == m_pConfig->eMode)
|
|
|
+ {
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(),HWND_TOP,m_monitorRect.left,m_monitorRect.top,0,0,SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if (m_pConfig->nWndWidth > m_monitorRect.Width())
|
|
|
+ {
|
|
|
+ m_pConfig->nWndWidth = m_monitorRect.Width();
|
|
|
+ }
|
|
|
+ if (m_pConfig->nWndHeight > m_monitorRect.Height())
|
|
|
+ {
|
|
|
+ m_pConfig->nWndHeight = m_monitorRect.Height();
|
|
|
+ }
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_monitorRect.left+m_pConfig->nWndX,
|
|
|
+ m_monitorRect.top+m_pConfig->nWndY,m_pConfig->nWndWidth,m_pConfig->nWndHeight,SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+ }
|
|
|
+
|
|
|
+ SetTimer(WNDTOPMOST_TIMERID, 10, 0);
|
|
|
+ SetTimer(FULLSCREEN_TIMERID, GetDoubleClickTime(), 0); // 开启Timer监视,防止WMP本身的全屏
|
|
|
+ m_bTimer = true;
|
|
|
+
|
|
|
+ m_settings = static_cast<CWMPSettings>(m_player->get_settings());
|
|
|
+ m_settings.put_autoStart(FALSE);
|
|
|
+ m_playlist = m_player->get_currentPlaylist();
|
|
|
+ if (strstr(m_pConfig->strNamePrefix, "S"))
|
|
|
+ {
|
|
|
+ m_playlist.put_name(_T("现场销售录音录像"));
|
|
|
+ }
|
|
|
+ else if (strstr(m_pConfig->strNamePrefix, "W"))
|
|
|
+ {
|
|
|
+ m_playlist.put_name(_T("二次见证录音录像"));
|
|
|
+ }
|
|
|
+ else if (strstr(m_pConfig->strNamePrefix, "OFL")) // edit by ly 20180224
|
|
|
+ {
|
|
|
+ m_playlist.put_name(_T("离线录音录像"));
|
|
|
+ }
|
|
|
+
|
|
|
+ CString videoPath("");
|
|
|
+ for(int i = 0; i != m_pConfig->nFileCnt; ++i)
|
|
|
+ {
|
|
|
+ videoPath.Format(_T("%s%s_%d.wmv"), m_pConfig->strRootPath, m_pConfig->strNamePrefix, i);
|
|
|
+ m_playlist.appendItem(m_player->newMedia(videoPath));
|
|
|
+ }
|
|
|
+
|
|
|
+ m_control = static_cast<CWMPControls>(m_player->get_controls());
|
|
|
+ m_control.play();
|
|
|
+ }
|
|
|
+ else if (m_pConfig->eMode == LOCALAUDIO) // 本地音频模式播放
|
|
|
+ {
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(),HWND_TOP,m_monitorRect.left,m_monitorRect.top,0,0,SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+
|
|
|
+ m_settings = static_cast<CWMPSettings>(m_player->get_settings());
|
|
|
+ m_settings.put_autoStart(FALSE);
|
|
|
+ m_playlist = m_player->get_currentPlaylist();
|
|
|
+ m_playlist.put_name(_T("可视柜台本地音频播放"));
|
|
|
+
|
|
|
+ // 每次加载1个文件播放,先播放第一个
|
|
|
+ for (int i = 0; i < m_pConfig->nFileCnt; i++){
|
|
|
+ CString audioPath("");
|
|
|
+ audioPath.Format(_T("%s%s"), (LPCSTR)m_pConfig->strRootPath, (LPCSTR)m_pConfig->strFileNames[i]);
|
|
|
+ m_playlist.appendItem(m_player->newMedia(audioPath));
|
|
|
+ }
|
|
|
+
|
|
|
+ m_control = static_cast<CWMPControls>(m_player->get_controls());
|
|
|
+ m_control.play();
|
|
|
+ }
|
|
|
+ else if (m_pConfig->eMode == LOCALVIDEO) // 本地视频模式播放
|
|
|
+ {
|
|
|
+ if (m_pConfig->bSimpleMode == true) // 简洁模式
|
|
|
+ {
|
|
|
+ m_player->put_uiMode(_T("none"));
|
|
|
+ // 去掉标题栏和边框
|
|
|
+ ModifyStyle(WS_CAPTION, 0, 0);
|
|
|
+ ModifyStyleEx(WS_EX_DLGMODALFRAME, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ SetTimer(FULLSCREEN_TIMERID, GetDoubleClickTime(), 0); // 开启Timer监视,防止WMP本身的全屏
|
|
|
+ m_bTimer = true;
|
|
|
+
|
|
|
+ m_settings = static_cast<CWMPSettings>(m_player->get_settings());
|
|
|
+ m_settings.put_autoStart(FALSE);
|
|
|
+ m_settings.put_volume(m_pConfig->nVolume); // 设置音量 add by ly 2017/06/06
|
|
|
+ m_playlist = m_player->get_currentPlaylist();
|
|
|
+ m_playlist.put_name(_T("可视柜台本地视频播放"));
|
|
|
+
|
|
|
+ if (m_pConfig->bFullScreen == true) // 全屏模式
|
|
|
+ {
|
|
|
+ //最大化
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_monitorRect.left,
|
|
|
+ m_monitorRect.top,m_monitorRect.Width(),m_monitorRect.Height(),SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (m_pConfig->nWndWidth > m_monitorRect.Width())
|
|
|
+ {
|
|
|
+ m_pConfig->nWndWidth = m_monitorRect.Width();
|
|
|
+ }
|
|
|
+ if (m_pConfig->nWndHeight > m_monitorRect.Height())
|
|
|
+ {
|
|
|
+ m_pConfig->nWndHeight = m_monitorRect.Height();
|
|
|
+ }
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_monitorRect.left+m_pConfig->nWndX,
|
|
|
+ m_monitorRect.top+m_pConfig->nWndY,m_pConfig->nWndWidth,m_pConfig->nWndHeight,SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+ }
|
|
|
+
|
|
|
+ // 每次加载1个文件播放,先播放第一个
|
|
|
+ if(m_pConfig->nFileCnt > 0)
|
|
|
+ {
|
|
|
+ CString videoPath("");
|
|
|
+ videoPath.Format(_T("%s%s"), (LPCSTR)m_pConfig->strRootPath, (LPCSTR)m_pConfig->strFileNames[0]);
|
|
|
+ m_player->put_URL(videoPath);
|
|
|
+
|
|
|
+ m_control = static_cast<CWMPControls>(m_player->get_controls());
|
|
|
+ m_control.play();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(SALESNOTICE == m_pConfig->eMode){
|
|
|
+ if (m_pConfig->bSimpleMode == true){
|
|
|
+ m_player->put_uiMode(_T("none"));
|
|
|
+ // 去掉标题栏和边框
|
|
|
+ ModifyStyle(WS_CAPTION, 0, 0);
|
|
|
+ ModifyStyleEx(WS_EX_DLGMODALFRAME, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ SetTimer(FULLSCREEN_TIMERID, GetDoubleClickTime(), 0); // 开启Timer监视,防止WMP本身的全屏
|
|
|
+ m_bTimer = true;
|
|
|
+
|
|
|
+ m_settings = static_cast<CWMPSettings>(m_player->get_settings());
|
|
|
+ m_settings.put_autoStart(FALSE);
|
|
|
+ m_playlist = m_player->get_currentPlaylist();
|
|
|
+
|
|
|
+ m_playlist.put_name(_T("可视柜台产品销售提示"));
|
|
|
+ if (m_pConfig->nWndWidth > m_monitorRect.Width()){
|
|
|
+ m_pConfig->nWndWidth = m_monitorRect.Width();
|
|
|
+ }
|
|
|
+ if (m_pConfig->nWndHeight > m_monitorRect.Height()){
|
|
|
+ m_pConfig->nWndHeight = m_monitorRect.Height();
|
|
|
+ }
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_monitorRect.left+m_pConfig->nWndX,
|
|
|
+ m_monitorRect.top+m_pConfig->nWndY,m_pConfig->nWndWidth,m_pConfig->nWndHeight,SWP_HIDEWINDOW);//HWND_TOP
|
|
|
+
|
|
|
+ CString videoPath("");
|
|
|
+ videoPath.Format(_T("%s%s"), m_pConfig->strRootPath, m_pConfig->strFileNames[0]);
|
|
|
+ m_playlist.appendItem(m_player->newMedia(videoPath));
|
|
|
+ m_control = static_cast<CWMPControls>(m_player->get_controls());
|
|
|
+ m_control.play();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return TRUE;
|
|
|
+}
|
|
|
+
|
|
|
+void CPlayerDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
+{
|
|
|
+ CDialogEx::DoDataExchange(pDX);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+BEGIN_MESSAGE_MAP(CPlayerDlg, CDialogEx)
|
|
|
+ ON_MESSAGE(WM_SETVOLUME_MESSAGE, &CPlayerDlg::OnSetVolumeMessage)
|
|
|
+ ON_WM_CLOSE()
|
|
|
+ ON_WM_SIZE()
|
|
|
+ ON_WM_NCLBUTTONDBLCLK()
|
|
|
+ ON_WM_NCHITTEST()
|
|
|
+ ON_WM_NCLBUTTONDOWN()
|
|
|
+ ON_WM_TIMER()
|
|
|
+ ON_WM_ERASEBKGND()
|
|
|
+END_MESSAGE_MAP()
|
|
|
+
|
|
|
+
|
|
|
+// CPlayerDlg 消息处理程序
|
|
|
+
|
|
|
+LRESULT CPlayerDlg::OnSetVolumeMessage( WPARAM wParam, LPARAM lParam )
|
|
|
+{
|
|
|
+ int nVolume = (int)lParam;
|
|
|
+ m_settings.put_volume(nVolume);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void CPlayerDlg::OnClose()
|
|
|
+{
|
|
|
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
+ EndPlay();
|
|
|
+ CDialogEx::OnClose();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CPlayerDlg::OnSize(UINT nType, int cx, int cy)
|
|
|
+{
|
|
|
+ if(!m_bInit) return;
|
|
|
+ CDialogEx::OnSize(nType, cx, cy);
|
|
|
+ // TODO: 在此处添加消息处理程序代码
|
|
|
+ m_player->MoveWindow(0, 0, cx, cy);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CPlayerDlg::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
|
|
|
+{
|
|
|
+ CDialogEx::OnNcLButtonDblClk(nHitTest, point);
|
|
|
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
+ if(nHitTest == HTCAPTION)
|
|
|
+ {
|
|
|
+ if (!m_bMax)
|
|
|
+ {
|
|
|
+ this->GetWindowRect(&m_savedWndRect);//保存窗口最大化之前的Rect
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_monitorRect.left,
|
|
|
+ m_monitorRect.top,m_monitorRect.Width(),m_monitorRect.Height(),SWP_SHOWWINDOW);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_savedWndRect.left,
|
|
|
+ m_savedWndRect.top,m_savedWndRect.Width(),m_savedWndRect.Height(),SWP_SHOWWINDOW);
|
|
|
+ }
|
|
|
+ m_bMax = !m_bMax;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CPlayerDlg::PlayStateChangeOcx1(long NewState)
|
|
|
+{
|
|
|
+ if(m_bInit)
|
|
|
+ {
|
|
|
+ switch(NewState)
|
|
|
+ {
|
|
|
+ case 3: // 播放状态
|
|
|
+ {
|
|
|
+ if (m_pConfig->eMode == SINGLE || m_pConfig->eMode == SALESRECORD)
|
|
|
+ {
|
|
|
+ CWMPMedia m_media = m_player->get_currentMedia();
|
|
|
+ long width = m_media.get_imageSourceWidth();
|
|
|
+ long height = m_media.get_imageSourceHeight();//HWND_TOPMOST
|
|
|
+ int border_w = GetSystemMetrics(SM_CXFRAME); //窗口边框的边缘宽度
|
|
|
+ int border_h = GetSystemMetrics(SM_CYFRAME); //窗口边框的边缘高度
|
|
|
+ int titlebar_h = GetSystemMetrics(SM_CYSIZE);
|
|
|
+
|
|
|
+ if (width > height)
|
|
|
+ {
|
|
|
+ long wnd_w = (long)(1.4*width+2*border_w);
|
|
|
+ long wnd_h = (long)(1.4*height+border_h+titlebar_h+140);
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_monitorRect.left+(m_monitorRect.Width()-wnd_w)/2,
|
|
|
+ m_monitorRect.top+(m_monitorRect.Height()-wnd_h)/2,wnd_w,wnd_h,SWP_SHOWWINDOW);//HWND_TOP
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ long wnd_w = (long)(0.8*width+2*border_w);
|
|
|
+ long wnd_h = (long)(0.8*height+border_h+titlebar_h+128);
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, m_monitorRect.left+(m_monitorRect.Width()-wnd_w)/2+336,
|
|
|
+ m_monitorRect.top+(m_monitorRect.Height()-wnd_h)/2-54,wnd_w,wnd_h,SWP_SHOWWINDOW);//HWND_TOP
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (m_pConfig->eMode == LOCALVIDEO)
|
|
|
+ {
|
|
|
+ this->ShowWindow(SW_SHOW);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2: // 暂停状态
|
|
|
+ break;
|
|
|
+ case 1: // 停止状态
|
|
|
+ {
|
|
|
+ if (m_pConfig->eMode == LOCALVIDEO || SALESNOTICE == m_pConfig->eMode)
|
|
|
+ {
|
|
|
+ // 隐藏窗口
|
|
|
+ this->ShowWindow(SW_HIDE);
|
|
|
+ m_nMediaInx = (m_nMediaInx+1)%m_pConfig->nFileCnt;
|
|
|
+ if (m_pConfig->nPlayCnt != 0) // 非循环播放
|
|
|
+ {
|
|
|
+ if (m_nMediaInx == 0)
|
|
|
+ {
|
|
|
+ m_nPlayCnt++;
|
|
|
+ }
|
|
|
+ if (m_pConfig->eMode == LOCALAUDIO)
|
|
|
+ {
|
|
|
+ //EndPlay();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (m_nPlayCnt == m_pConfig->nPlayCnt)//播放次数到了
|
|
|
+ {
|
|
|
+ // 结束播放
|
|
|
+ //EndPlay();
|
|
|
+ SetEvent(m_pConfig->h_WMPPlayEndEvent);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (m_pConfig->nPlayInterval >= 0)
|
|
|
+ {
|
|
|
+ SetTimer(INTERVAL_TIMERID, m_pConfig->nPlayInterval, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 8: // 播放列表单曲结束
|
|
|
+ if (m_pConfig->eMode == LOCALAUDIO)
|
|
|
+ {
|
|
|
+ m_pConfig->nFileCnt--;
|
|
|
+
|
|
|
+ if (m_pConfig->nFileCnt == 0){
|
|
|
+ SetEvent(m_pConfig->h_WMPPlayEndEvent);// play end
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 9: // 缓冲状态
|
|
|
+ case 10:// 开始状态
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+BOOL CPlayerDlg::EndPlay()
|
|
|
+{
|
|
|
+ // 停止计时器
|
|
|
+ if (m_bTimer)
|
|
|
+ {
|
|
|
+ m_bTimer = false;
|
|
|
+ KillTimer(FULLSCREEN_TIMERID);
|
|
|
+ }
|
|
|
+
|
|
|
+ KillTimer(WNDTOPMOST_TIMERID);
|
|
|
+ // 停止播放
|
|
|
+ m_bInit = false; // new added
|
|
|
+ KillTimer(INTERVAL_TIMERID); // new added
|
|
|
+
|
|
|
+ m_control.stop();
|
|
|
+
|
|
|
+ m_playlist = m_player->get_currentPlaylist(); // new added
|
|
|
+ m_playlist.clear(); // new added
|
|
|
+
|
|
|
+ m_player->close();
|
|
|
+
|
|
|
+ m_player->DestroyWindow(); // new added
|
|
|
+
|
|
|
+ // 关闭窗口
|
|
|
+ EndDialog(IDCANCEL);
|
|
|
+
|
|
|
+ return TRUE;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CPlayerDlg::OnNcHitTest(CPoint point)
|
|
|
+{
|
|
|
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
+ int ret = CDialogEx::OnNcHitTest(point);
|
|
|
+
|
|
|
+ if(HTTOP == ret || HTBOTTOM == ret || HTLEFT == ret || HTRIGHT == ret ||
|
|
|
+ HTBOTTOMLEFT == ret || HTBOTTOMRIGHT == ret || HTTOPLEFT == ret ||
|
|
|
+ HTTOPRIGHT == ret || HTCAPTION == ret)
|
|
|
+ return HTCLIENT;
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CPlayerDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
|
|
|
+{
|
|
|
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
+ if(HTTOP == nHitTest || HTBOTTOM == nHitTest || HTLEFT == nHitTest || HTRIGHT == nHitTest ||
|
|
|
+ HTBOTTOMLEFT == nHitTest || HTBOTTOMRIGHT == nHitTest || HTTOPLEFT == nHitTest ||
|
|
|
+ HTTOPRIGHT == nHitTest || HTCAPTION == nHitTest)
|
|
|
+ return;
|
|
|
+ CDialogEx::OnNcLButtonDown(nHitTest, point);
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+static bool isWndTopMost(HWND hwnd)
|
|
|
+{
|
|
|
+ if(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CPlayerDlg::OnTimer(UINT_PTR nIDEvent)
|
|
|
+{
|
|
|
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
+ if (nIDEvent == FULLSCREEN_TIMERID)
|
|
|
+ {
|
|
|
+ if (m_player->get_fullScreen() == TRUE)
|
|
|
+ {
|
|
|
+ m_player->put_fullScreen(FALSE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (nIDEvent == INTERVAL_TIMERID)
|
|
|
+ {
|
|
|
+ // 每间隔m_nPlayInterval毫秒重复播放1次
|
|
|
+ CString mediaPath("");
|
|
|
+ mediaPath.Format(_T("%s%s"), (LPCSTR)m_pConfig->strRootPath, (LPCSTR)m_pConfig->strFileNames[m_nMediaInx]);
|
|
|
+ m_player->put_URL(mediaPath);
|
|
|
+
|
|
|
+ m_control = static_cast<CWMPControls>(m_player->get_controls());
|
|
|
+ m_control.play();
|
|
|
+
|
|
|
+ KillTimer(INTERVAL_TIMERID);
|
|
|
+ }
|
|
|
+ else if(WNDTOPMOST_TIMERID == nIDEvent)
|
|
|
+ {
|
|
|
+ //if (false == isWndTopMost(this->GetSafeHwnd()))
|
|
|
+ {
|
|
|
+ ::SetWindowPos(this->GetSafeHwnd(), HWND_TOPMOST, 0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CDialogEx::OnTimer(nIDEvent);
|
|
|
+}
|
|
|
+
|
|
|
+// 禁止刷新背景
|
|
|
+BOOL CPlayerDlg::OnEraseBkgnd(CDC* pDC)
|
|
|
+{
|
|
|
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
+
|
|
|
+ //return CDialogEx::OnEraseBkgnd(pDC);
|
|
|
+ return TRUE;
|
|
|
+}
|
|
|
+
|
|
|
+void CPlayerDlg::PlayerLog(eplayer_loglevel elvel, const char* fmt, ...)
|
|
|
+{
|
|
|
+ if (m_callback.debug) {
|
|
|
+ va_list arg;
|
|
|
+ va_start(arg, fmt);
|
|
|
+ if (*m_callback.debug) {
|
|
|
+ (*m_callback.debug)(elvel, m_callback.user_data, fmt, arg);
|
|
|
+ }
|
|
|
+ va_end(arg);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void CPlayerDlg::PlayerLogEvent(eplayer_monitor_error errortype, const char* errmsg)
|
|
|
+{
|
|
|
+ if (m_callback.player_event) {
|
|
|
+ if (*m_callback.player_event) {
|
|
|
+ (*m_callback.player_event)(m_callback.user_data, errortype, errmsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|