如何在不使用directshow阻止事件的情况下播放视频 [英] How to play the video without blocking the events using directshow
本文介绍了如何在不使用directshow阻止事件的情况下播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图播放包含播放,暂停和停止等一些基本控件的视频。如果我使用此代码
Am trying to play the video with some of the basic controls included like play, pause and stop. If i use this code
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}
它等待视频完成,所以我不能暂停播放视频。
所以我用(响应事件)
It waits for the video to complete so i cant pause the playing video.
so i used (responding to event)
#define WM_GRAPHNOTIFY WM_APP + 1
IMediaEventEx *g_pEvent = NULL;
g_pGraph->QueryInterface(IID_IMediaEventEx, (void **)&g_pEvent);
g_pEvent->SetNotifyWindow((OAHWND)g_hwnd, WM_GRAPHNOTIFY, 0);
case WM_GRAPHNOTIFY:
HandleGraphEvent();
break;
void HandleGraphEvent()
{
// Disregard if we don't have an IMediaEventEx pointer.
if (g_pEvent == NULL)
{
return;
}
// Get all the events
long evCode;
LONG_PTR param1, param2;
HRESULT hr;
while (SUCCEEDED(g_pEvent->GetEvent(&evCode, ¶m1, ¶m2, 0)))
{
g_pEvent->FreeEventParams(evCode, param1, param2);
switch (evCode)
{
case EC_COMPLETE: // Fall through.
case EC_USERABORT: // Fall through.
case EC_ERRORABORT:
CleanUp();
PostQuitMessage(0);
return;
}
}
}
// Disable event notification before releasing the graph.
g_pEvent->SetNotifyWindow(NULL, 0, 0);
g_pEvent->Release();
g_pEvent = NULL;
我评论了waitforcompletion方法,它执行成功,但视频没有播放。
欢迎您提出建议。
I commented the waitforcompletion method, it executed sucessfully but the video was not played.
Your suggestions are welcome.
推荐答案
我上面给出的代码(回应事件)是现在效果很好。
The code which i given above (Responding to event) is works well now.
这篇关于如何在不使用directshow阻止事件的情况下播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文