媒体播放器全屏显示E_UNEXPECTED [英] Media player full screen gives E_UNEXPECTED

查看:93
本文介绍了媒体播放器全屏显示E_UNEXPECTED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我一直试图让媒体播放器全屏播放。我在下面的代码中获得了hrFull的运行时异常,其中说E_UNEXPECTED灾难性故障。我看到这个,当我提出一个断点,其他明智的代码运行良好,虽然它没有全屏幕。通过右键单击正在运行的媒体播放器并选择全屏缩放,我可以全屏播放。

我的目标是点击一个按钮,全屏播放。



以下代码就是我正在使用的代码。此代码位于OnInitDialog中。



 LPUNKNOWN pUnknown = m_MediaPlayer.GetControlUnknown(); 
// LPUNKNOWN pUnknown1 = m_MediaPlayer1.GetControlUnknown();


HRESULT hr = pUnknown-> QueryInterface( __ uuidof (IWMPPlayer),( void * *)及m_pWMPPlayer);
// HRESULT hr1 = pUnknown1-> QueryInterface(__ uuidof(IWMPPlayer),(void **)& ; m_pWMPPlayer1);


if (SUCCEEDED(hr))
{
CComBSTR strMovie = _T( C:\\movie \\Hero 2004.mp4 );
m_pWMPPlayer-> put_URL(strMovie);


VARIANT_BOOL bSc = VARIANT_TRUE;
HRESULT hrFull;

hrFull = m_pWMPPlayer-> put_fullScreen(bSc);

}



任何方向都是最受欢迎的。

问候,

Rakesh

解决方案

似乎全屏模式要求实际播放视频。当您的代码尝试切换到全屏模式时,媒体播放器可能尚未完成启动。



所以你必须要等到州改变了。这可以使用 IWMPEvents :: PlayStateChange事件来完成( Windows) [ ^ ]。当状态变为播放时,从处理程序内部激活全屏模式(我没有找到C ++状态值的描述,但根据 AxWindowsMediaPlayer对象的PlayStateChange事件(Windows) [ ^ ])。



请参阅使用C ++处理事件(Windows) [< a href =https://technet.microsoft.com/en-us/sysinternals/dd563019target =_ blanktitle =New Window> ^ ]有关处理媒体播放器事件的示例。

Hello,
I have been trying to get the media player to play in full screen. I get a runtime exception for hrFull )below in code) which says E_UNEXPECTED catastrophic failure. I see this when I put a break point other wise the code runs fine though it doesnt go to full screen. By right clicking on the running media player and selecting zoom full screen I am able to play in full screen.
My objective is to have a button clicking which should play full screen.

The code below is what I am using. This code is in OnInitDialog.

LPUNKNOWN pUnknown = m_MediaPlayer.GetControlUnknown();
//LPUNKNOWN pUnknown1 = m_MediaPlayer1.GetControlUnknown();


HRESULT hr = pUnknown->QueryInterface(__uuidof(IWMPPlayer), (void**)&m_pWMPPlayer);
//HRESULT hr1 = pUnknown1->QueryInterface(__uuidof(IWMPPlayer), (void**)&m_pWMPPlayer1);


if (SUCCEEDED(hr))
{
CComBSTR strMovie = _T("C:\\movie\\Hero 2004.mp4");
m_pWMPPlayer->put_URL(strMovie);


VARIANT_BOOL bSc = VARIANT_TRUE;
HRESULT hrFull;

hrFull = m_pWMPPlayer->put_fullScreen(bSc);

}


Any direction is most appreciated.
Regards,
Rakesh

解决方案

It seems that the full screen mode requires that the video is actually played. When your code tries to switch to full screen mode, the media player has probably not finished his startup.

So you have to wait until the state has changed. This can be done using the IWMPEvents::PlayStateChange event (Windows)[^]. From inside that handler activate the full screen mode when the status changes to playing (I did not found a description for the C++ status values but playing might by a value of 3 according to PlayStateChange Event of the AxWindowsMediaPlayer Object (Windows)[^]).

See Handling Events in C++ (Windows)[^] for an example on handling media player events.


这篇关于媒体播放器全屏显示E_UNEXPECTED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆