Example #1
0
TBool CWindow::KeyEventL(TInt aKeyCode)
{
	UtilityTools::WriteLogsL(_L("CWindow::KeyEventL"));
	TBool keyResult = ETrue;
	if(iChildWindow)
	{
		UtilityTools::WriteLogsL(_L("CWindow::KeyEventL iChildWindow Start"));
		UtilityTools::WriteLogsL(_L("CWindow::KeyEventL iChildWindow child type = %d"),iChildWindow->GetWindowType());
		keyResult = iChildWindow->KeyEventL(aKeyCode);
		UtilityTools::WriteLogsL(_L("CWindow::KeyEventL iChildWindow End"));
	}
	else
	{
		keyResult = HandleEachControlKeyL(aKeyCode);
		if(!keyResult)
		{
			keyResult = DoKeyEventL(aKeyCode);
		}
		if(!keyResult && iCanPopUpWindow)
		{
			keyResult = ETrue;
			switch(aKeyCode)
			{
			case '*':		//用户按下"*"键,打开播放器界面
				if(EOpenFileWindow_Music != iWindowType)
				{
					CreateChildWindow(EOpenFileWindow_Music);
				}
				break;

			case '#':		//用户按下"#"键,打开下载管理界面
				if(EDownloadManagerWindow != iWindowType&&iMainEngine.GetLoginType()==1)
				{
					CreateChildWindow(EDownloadManagerWindow);
				}
				break;

			case '0':		//用户按下"0"键,打开已下载界面
				if(EDownloadedWindow != iWindowType)
				{
					CreateChildWindow(EDownloadedWindow);
				}
				break;

			default:
				keyResult = EFalse;
				break;
			}
		}
	}
	UtilityTools::WriteLogsL(_L("CWindow::KeyEventL End"));
	return keyResult;
}
Example #2
0
CWindow* CWindow::MakeChildWindow(TInt aWindowType)
{
	CreateChildWindow(aWindowType);
	return iChildWindow;
}
Example #3
0
HRESULT tTVPMFPlayer::CreateVideoPlayer() {
	if( MediaSession.p ) {
		return S_OK;	// 既に作成済み
	}

	HRESULT hr = CreateChildWindow();
	if( hr != S_OK ) return hr;

	HWND hWnd = GetChildWindow();
	if( hWnd == NULL || hWnd == INVALID_HANDLE_VALUE )
		return E_FAIL;

	if( FAILED(hr = MFCreateMediaSession( NULL, &MediaSession )) ) {
		TVPThrowExceptionMessage(L"Faild to create Media session.");
	}
	if( FAILED(hr = MediaSession->BeginGetEvent( PlayerCallback, NULL )) ) {
		TVPThrowExceptionMessage(L"Faild to begin get event.");
	}
	CComPtr<IMFSourceResolver> pSourceResolver;
	if( FAILED(hr = MFCreateSourceResolver(&pSourceResolver)) ) {
		TVPThrowExceptionMessage(L"Faild to create source resolver.");
	}
	MF_OBJECT_TYPE ObjectType = MF_OBJECT_INVALID;
	CComPtr<IUnknown> pSource;
	if( FAILED(hr = pSourceResolver->CreateObjectFromByteStream( ByteStream, StreamName.c_str(), MF_RESOLUTION_MEDIASOURCE, NULL, &ObjectType, (IUnknown**)&pSource )) ) {
	//if( FAILED(hr = pSourceResolver->CreateObjectFromURL( L"C:\\krkrz\\bin\\win32\\data\\test.mp4",
	//	MF_RESOLUTION_MEDIASOURCE, NULL, &ObjectType, (IUnknown**)&pSource)) ) {
		TVPThrowExceptionMessage(L"Faild to open stream.");
	}
	if( ObjectType != MF_OBJECT_MEDIASOURCE ) {
		TVPThrowExceptionMessage(L"Invalid media source.");
	}
	//CComPtr<IMFMediaSource> pMediaSource;
	if( FAILED(hr = pSource.QueryInterface(&MediaSource)) ) {
		TVPThrowExceptionMessage(L"Faild to query Media source.");
	}
	if( FAILED(hr = MFCreateTopology(&Topology)) ) {
		TVPThrowExceptionMessage(L"Faild to create Topology.");
	}
	CComPtr<IMFPresentationDescriptor> pPresentationDescriptor;
	if( FAILED(hr = MediaSource->CreatePresentationDescriptor(&pPresentationDescriptor)) ) {
		TVPThrowExceptionMessage(L"Faild to create Presentation Descriptor.");
	}
	DWORD streamCount;
	if( FAILED(hr = pPresentationDescriptor->GetStreamDescriptorCount(&streamCount)) ) {
		TVPThrowExceptionMessage(L"Faild to get stream count.");
	}
	if( streamCount < 1 ) {
		TVPThrowExceptionMessage(L"Not found media stream.");
	}
	for( DWORD i = 0; i < streamCount; i++ ) {
		if( FAILED(hr = AddBranchToPartialTopology(Topology, MediaSource, pPresentationDescriptor, i, hWnd)) ) {
			TVPThrowExceptionMessage(L"Faild to add nodes.");
		}
	}
	pPresentationDescriptor->GetUINT64(MF_PD_DURATION, (UINT64*)&HnsDuration);
	
	if( FAILED(hr = MediaSession->SetTopology( 0, Topology )) ) {
		TVPThrowExceptionMessage(L"Faild to set topology.");
	}
	return hr;
}