Click here to Skip to main content
15,067,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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");


hrFull = m_pWMPPlayer->put_fullScreen(bSc);


Any direction is most appreciated.
Updated 19-Jan-16 0:15am

1 solution

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.
Member 11380615 19-Jan-16 11:50am
Thanks You so much.
Full screen mode worked.
Jochen Arndt 19-Jan-16 12:03pm
Thank you for your feedback and good to know that it is working now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900