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();
}
Beispiel #2
0
BOOL CMediaVisDlg::EnumerateWrapped(LPCTSTR pszName, REFCLSID pCLSID, LPCTSTR pszCLSID)
{
	IWrappedPluginControl* pPlugin = NULL;

	HINSTANCE hRes = AfxGetResourceHandle();

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

	AfxSetResourceHandle( hRes );

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

	LPSAFEARRAY pArray = NULL;
	hr = pPlugin->Enumerate( &pArray );

	pPlugin->Release();

	if ( FAILED(hr) || pArray == NULL ) return FALSE;

	LONG pIndex[2] = { 0, 0 };
	SafeArrayGetUBound( pArray, 2, &pIndex[1] );

	if ( pIndex[1] < 0 )
	{
		SafeArrayDestroy( pArray );
		return TRUE;
	}

	for ( ; pIndex[1] >= 0; pIndex[1]-- )
	{
		CString strName, strPath;
		BSTR bsValue = NULL;

		strName = pszName;
		strName += L": ";

		pIndex[0] = 0;
		SafeArrayGetElement( pArray, pIndex, &bsValue );
		strName += bsValue;
		SysFreeString( bsValue );
		bsValue = NULL;

		pIndex[0] = 1;
		SafeArrayGetElement( pArray, pIndex, &bsValue );
		strPath = bsValue;
		SysFreeString( bsValue );
		bsValue = NULL;

		AddPlugin( strName, pszCLSID, strPath );
	}

	SafeArrayDestroy( pArray );

	return TRUE;
}
Beispiel #3
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();
}