本文整理汇总了C++中VideoPtr::Rendering方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoPtr::Rendering方法的具体用法?C++ VideoPtr::Rendering怎么用?C++ VideoPtr::Rendering使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoPtr
的用法示例。
在下文中一共展示了VideoPtr::Rendering方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadVideo
bool DShowPlayer::LoadVideo(VideoPtr pVideo, const std::wstring& fileName)
{
if (pVideo->Rendering())
{
ShowMessage(L"Videos can't be loaded while rendering - DShowPlayer::LoadVideo", GSMT_ERROR);
return false;
}
m_pVideo = pVideo;
D3D9VideoInfoPtr videoInfo;
try
{
videoInfo = boost::any_cast<D3D9VideoInfoPtr>(m_pVideo->GetVideoInfo());
}
catch (const boost::bad_any_cast &)
{
ShowMessage(L"Invalid D3D9VideoInfoPtr object - DShowPlayer::LoadVideo", GSMT_ERROR);
return false;
}
m_data.hWnd = videoInfo->m_hWnd;
if (FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
m_pVideo->Message(L"Failed while trying to start COM interface - DShowPlayer::LoadVideo", GSMT_ERROR);
return false;
}
bool failed = false;
if (FAILED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&m_data.pGB))) failed = true;
if (FAILED(m_data.pGB->QueryInterface(IID_IMediaControl, (void **)&m_data.pMC))) failed = true;
if (FAILED(m_data.pGB->QueryInterface(IID_IVideoWindow, (void **)&m_data.pVW))) failed = true;
if (FAILED(m_data.pGB->QueryInterface(IID_IMediaEventEx, (void **)&m_data.pME))) failed = true;
if (FAILED(m_data.pGB->QueryInterface(IID_IMediaSeeking, (void**)&m_data.pMS))) failed = true;
if (FAILED(m_data.pGB->QueryInterface(IID_IBasicAudio, (void**)&m_data.pBA))) failed = true;
if (failed)
{
m_pVideo->Message(L"Failed while trying to query COM interfaces - DShowPlayer::LoadVideo", GSMT_ERROR);
return false;
}
if (FAILED(m_data.pGB->RenderFile(fileName.c_str(), NULL)))
{
std::wstring message = fileName;
message += L"\nFailed while trying to load and decode the video - DShowPlayer::LoadVideo";
m_pVideo->Message(message, GSMT_ERROR);
return false;
}
if (FAILED(m_data.pVW->put_MessageDrain((OAHWND)m_data.hWnd)))
{
std::wstring message = fileName;
message += L" is not a video file. - DShowPlayer::LoadVideo";
m_pVideo->Message(message, GSMT_ERROR);
return false;
}
//m_data.pVW->put_WindowState(SW_SHOWNOACTIVATE);
m_data.pVW->put_Owner((OAHWND)m_data.hWnd);
m_data.pVW->put_WindowStyle(WS_CHILD);
m_data.pVW->put_WindowStyleEx(WS_EX_NOACTIVATE | WS_EX_TOPMOST);
m_data.pMC->Pause();
long lWidth, lHeight;
m_data.pVW->GetMinIdealImageSize(&lWidth, &lHeight);
m_size.x = lWidth * (long)m_pVideo->GetScreenSize().x/16;
m_size.y = lHeight * (long)m_pVideo->GetScreenSize().y/16;
Vector2i pos(0, 0);
m_pos = pos;
m_data.pVW->SetWindowPosition((long)m_pos.x,(long)m_pos.y, (long)m_size.x, (long)m_size.y);
return true;
}
示例2: PlayCutscene
GS_PLAYER_INFO PlayCutscene(VideoPtr pVideo, const std::wstring& fileName,
InputPtr pInput, const GS_KEY escapeKey)
{
if (!pVideo)
{
ShowMessage(L"Invalid video handler - gs2d::PlayCutscene", GSMT_ERROR);
return GSPI_FAILED;
}
GS_PLAYER_INFO info = GSPI_FINISHED;
//pVideo->TurnLoopManagerOff();
const bool rendering = pVideo->Rendering();
if (rendering)
pVideo->EndSpriteScene();
PlayerPtr player = CreatePlayer(pVideo, fileName);
if (!player)
{
ShowMessage(L"Failed while trying to load the video - gs2d::PlayCutscene", GSMT_ERROR);
if (rendering)
pVideo->BeginSpriteScene();
return GSPI_FAILED;
}
pVideo->EnableMediaPlaying(true);
player->SetFullscreen();
player->Rewind();
player->Play();
while (!player->IsFinished())
{
player->UpdateVideo();
const Video::APP_STATUS status = pVideo->HandleEvents();
if (status == Video::APP_QUIT)
{
info = GSPI_CLOSE_WINDOW;
break;
}
else
{
if (status == Video::APP_SKIP)
continue;
}
if (pInput)
{
pInput->Update();
if (pInput->GetKeyState(escapeKey) == GSKS_HIT)
{
info = GSPI_SKIPPED;
break;
}
}
}
if (rendering)
pVideo->BeginSpriteScene();
pVideo->EnableMediaPlaying(false);
return info;
}