这里使用OpenCV来创建播放窗口的
#include <stdio.h>
#include <iostream>
#include "Windows.h"
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/opencv.hpp>
#include "plaympeg4.h"
using namespace std;
//LONG和BOOL在Windows.h里
LONG nPort = -1; //播放端口
BOOL bFlag = false; //标志位
int main()
{
//获取播放库端口号
bFlag = PlayM4_GetPort(&nPort);
//打开待播放的文件
bFlag = PlayM4_OpenFile(nPort, LPSTR("test.mp4"));
if (bFlag == FALSE)
{
int nErr = PlayM4_GetLastError(nPort);
printf("Open file failed %d!", nErr);
return 0;
}
//PlayM4_SetPicQuality(nPort,true);
cv::namedWindow("192.168.1.64", 0);
HWND h = (HWND)cvGetWindowHandle("192.168.1.64");
if (h == 0)
{
std::cout << "窗口创建失败" << std::endl;
}
// 开始播放文件,使用label的句柄
PlayM4_Play(nPort, h);
//播放声音
PlayM4_PlaySound(nPort);
cv::waitKey(0);
return 0;
}