解決libVLC無法響應鼠標消息


參考:

https://blog.jianchihu.net/player-based-on-libvlc.html

自己在Qt上的實現:

頭文件

libvlc_instance_t * m_inst;
...
...
HWND parentwnd;//播放句柄
QWidget* m_videoWdg;//播放窗口

 

源文件

BOOL CALLBACK EnumerateVLC(HWND hWndvlc, LPARAM lParam)
{

  if (!hWndvlc)
  {
    return FALSE;
  }

  EnableWindow(hWndvlc, FALSE);

  // And kill timer, i only need get this handle one time.
  //timer->stop();

  return TRUE;

}


構造函數里面:

{
  m_pTimer = nullptr;
  m_pTimer = new QTimer(this);
  connect(m_pTimer, SIGNAL(timeout()), this, SLOT(onTime()));

}


播放函數里面,獲取到播放窗口的句柄

{
  m_inst = libvlc_new(0, NULL);
  ...
  ...
  HWND screen_hwnd = (HWND)m_videoWdg->winId();
  parentwnd =screen_hwnd;

  libvlc_media_player_set_hwnd(m_mp, screen_hwnd);

  .....

  m_pTimer->start(1000);

  Sleep(1);
}

//定時器函數
void StationCameraPlay::onTime()
{
  if (!parentwnd)
  {
    return;
  }

  EnumChildWindows(parentwnd, EnumerateVLC, NULL);

  m_pTimer->stop();
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM