Exemplo n.º 1
0
void CMediaVisDlg::OnSetup()
{
	int nItem = m_wndList.GetNextItem( -1, LVIS_SELECTED );
	if ( nItem < 0 ) return;

	CString strCLSID	= m_wndList.GetItemText( nItem, 1 );
	CString strPath		= m_wndList.GetItemText( nItem, 2 );

	CLSID pCLSID;
	if ( ! GUIDX::Decode( strCLSID, &pCLSID ) ) return;
	if ( ! Plugins.LookupEnable( pCLSID, TRUE ) ) return;

	IAudioVisPlugin* pPlugin = NULL;

	if ( Settings.MediaPlayer.VisCLSID == strCLSID &&
		 Settings.MediaPlayer.VisPath == strPath )
	{
		IMediaPlayer* pPlayer = ( m_pFrame != NULL ) ? m_pFrame->GetPlayer() : NULL;

		if ( pPlayer != NULL )
		{
			pPlayer->GetPlugin( &pPlugin );

			if ( pPlugin != NULL )
			{
				pPlugin->Configure();
				pPlugin->Release();
				return;
			}
		}
	}

	HINSTANCE hRes = AfxGetResourceHandle();

	HRESULT hr = CoCreateInstance( pCLSID, NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER,
		IID_IAudioVisPlugin, (void**)&pPlugin );

	AfxSetResourceHandle( hRes );

	if ( FAILED(hr) || pPlugin == NULL ) return;

	if ( strPath.GetLength() )
	{
		IWrappedPluginControl* pWrap = NULL;
		hr = pPlugin->QueryInterface( IID_IWrappedPluginControl, (void**)&pWrap );
		if ( SUCCEEDED(hr) && pWrap != NULL )
		{
			BSTR bsPath = strPath.AllocSysString();
			pWrap->Load( bsPath, 0 );
			pWrap->Release();
			SysFreeString( bsPath );
		}
	}

	pPlugin->Configure();
	pPlugin->Release();
}
Exemplo n.º 2
0
void CMediaVisDlg::OnSetup()
{
	int nItem = m_wndList.GetNextItem( -1, LVIS_SELECTED );
	if ( nItem < 0 ) return;

	CString strCLSID = m_wndList.GetItemText( nItem, 1 );
	CString strPath  = m_wndList.GetItemText( nItem, 2 );

	CLSID pCLSID;
	if ( ! Hashes::fromGuid( strCLSID, &pCLSID ) ) return;
	if ( ! Plugins.LookupEnable( pCLSID ) ) return;

	IAudioVisPlugin* pPlugin = NULL;

	if ( Settings.MediaPlayer.VisCLSID == strCLSID &&
		 Settings.MediaPlayer.VisPath == strPath )
	{
		IMediaPlayer* pPlayer = ( m_pFrame != NULL ) ? m_pFrame->GetPlayer() : NULL;

		if ( pPlayer != NULL )
		{
			pPlayer->GetPlugin( &pPlugin );

			if ( pPlugin != NULL )
			{
				pPlugin->Configure();
				pPlugin->Release();
				return;
			}
		}
	}

	HINSTANCE hRes = AfxGetResourceHandle();

	HRESULT hr = CoCreateInstance( pCLSID, NULL, CLSCTX_ALL, IID_IAudioVisPlugin, (void**)&pPlugin );

	AfxSetResourceHandle( hRes );

	if ( FAILED( hr ) || pPlugin == NULL ) return;

	if ( ! strPath.IsEmpty() )
	{
		IWrappedPluginControl* pWrap = NULL;
		hr = pPlugin->QueryInterface( IID_IWrappedPluginControl, (void**)&pWrap );
		if ( SUCCEEDED( hr ) && pWrap != NULL )
		{
			pWrap->Load( CComBSTR( strPath ), 0 );
			pWrap->Release();
		}
	}

	pPlugin->Configure();
	pPlugin->Release();
}