⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertydlg.cpp

📁 media player 控件源码 用EVC编译可以进行对WINCE下media player控制
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        audioInfo->lpwcCodecBitrate = NULL;
        audioInfo->bstrCodecDescription = L"";
        audioInfo->bSecure = FALSE;

        if (NULL != piba)
        {
            IBaseFilter *pibf = NULL;
            piba->QueryInterface( IID_IBaseFilter, (void **)&pibf );
            if ( pibf != NULL )
            {
                IEnumPins *piep = NULL;
                DWORD lFetched;
            
                IPin *pp;
                pibf->EnumPins( &piep );
                if ( piep != NULL )
                {
                    piep->Reset();
                
                    while ( (NOERROR == piep->Next( 1, &pp, &lFetched ) ) && ( pp != NULL ) )
                    {
                        AM_MEDIA_TYPE mt;
                        if ( SUCCEEDED( pp->ConnectionMediaType( &mt ) ) )
                        {
                            if ( mt.formattype == FORMAT_WaveFormatEx )
                            {
                                WAVEFORMATEX *pwfx = ( WAVEFORMATEX * )mt.pbFormat;
                                if ( pwfx != NULL )
                                {
                                    *(&audioInfo->wfmtWaveFormat) = *pwfx;
                                    hResult = S_OK;

                                    if( mt.cbFormat )
                                        CoTaskMemFree( mt.pbFormat );
                                    pp->Release();
                                    pp = NULL;
                                    break;
                                }
                                else
                                {
                                    hResult = E_POINTER;
                                }
                            }
                            else
                            {
                                hResult = S_FALSE;
                            }
                            // AM_MEDIA_TYPE is a structure on the stack, NOT an object.
                            // When it goes out of scope, it will not clean up its internal members.
                            if( mt.cbFormat )
                                CoTaskMemFree( mt.pbFormat );
                        }

                        pp->Release();
                        pp = NULL;
                    }
                    piep->Release();
                }
                pibf->Release();
            }
        }

        if (NULL != pnsep)
        {
            long codecCount = 0;
            if( SUCCEEDED( g_pPlayerWindow->m_pMP->get_CodecCount( &codecCount ) ) 
                && codecCount )
            {
                int i;
                for( i = 1; i <= codecCount; i++ )
                {
                    BSTR codecDesc;
                    if( SUCCEEDED( g_pPlayerWindow->m_pMP->GetCodecDescription( i, &codecDesc ) )
                        && wcsstr( codecDesc, L"Audio" ) )
                    {
                        LPWSTR comma;
                        if( comma = wcsrchr( codecDesc, L'(' ) )
                        {
                            WCHAR kbps[4] = L"";
                            *(comma++) = L'\0';
                            while( *comma == L' ' )
                                comma++;
                            if( swscanf( comma, L"%s", kbps ) == 1 )
                            {
                                audioInfo->lpwcCodecBitrate = new WCHAR[ 16 ];
                                wsprintf( audioInfo->lpwcCodecBitrate, L"%s Kbps", kbps );
                            }
                        }
                        else
                        {
                            audioInfo->lpwcCodecBitrate = L"";
                        }
                        audioInfo->bstrCodecDescription = codecDesc;
                        hResult = S_OK;
                        break;
                    }
                } // for each codec, until audio is found
            } // get_CodecCount succeeded and count > 0
        } // g_pPlayerWindow->m_pMP is valid

#ifdef UNDER_CE
        if( NULL != psmc )
        {
            psmc->get_IsSecure( &audioInfo->bSecure );
            hResult = S_OK;
        }
#endif /* UNDER_CE */
    }

    return hResult;
}

///////////////////////////////////////////////////////////////////////////////
// Name: CPropertyDlg::Update()
// Desc: This function is called when the dialog receives a PD_UPDATE message.
//       It then updates the filename and filters in the dialog.
///////////////////////////////////////////////////////////////////////////////
void CPropertyDlg::Update(TCHAR *szFilename)
{
    IBasicAudio           * piba  = NULL;
    IAMNetShowExProps     * pnsep = NULL;
    IAMSecureMediaContent * psmc  = NULL;

    SIZE size;
    LONG cx = 0;;
    HDC  hdc;

    hdc = ::GetDC(m_hListView);

    g_pPlayerWindow->FindInterfaceOnGraph(IID_IBasicAudio,           (void**)&piba);
    g_pPlayerWindow->FindInterfaceOnGraph(IID_IAMNetShowExProps,     (void**)&pnsep);
    g_pPlayerWindow->FindInterfaceOnGraph(IID_IAMSecureMediaContent, (void**)&psmc);

    ListView_DeleteAllItems( m_hListView );

    int itemNumber = 0;
    BSTR property = NULL;
    LVITEM item;
    item.mask = LVIF_TEXT;
    item.iSubItem = 0;
    item.state = 0;
    item.stateMask = 0;

    // Fill in our Show Title
    g_pPlayerWindow->m_pMP->GetMediaInfoString( mpShowTitle, &property );
    if( property )
    {
        if( *property )
        {
            item.iItem = itemNumber;
            item.pszText = L"Show Title:";
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            item.iItem = itemNumber;
            item.pszText = property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
        SysFreeString(property);
        property = NULL;
    }

    // Fill in our Show Author
    g_pPlayerWindow->m_pMP->GetMediaInfoString( mpShowAuthor, &property );
    if( property )
    {
        if( *property )
        {
            item.iItem = itemNumber;
            item.pszText = L"Show Author:";
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            item.iItem = itemNumber;
            item.pszText = property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
        SysFreeString(property);
        property = NULL;
    }

    // Fill in our Show Copyright
    g_pPlayerWindow->m_pMP->GetMediaInfoString( mpShowCopyright, &property );
    if( property )
    {
        if( *property )
        {
            item.iItem = itemNumber;
            item.pszText = L"Show Copyright:";
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            item.iItem = itemNumber;
            item.pszText = property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
        SysFreeString(property);
        property = NULL;
    }

    // Fill in our Clip Title
    g_pPlayerWindow->m_pMP->GetMediaInfoString( mpClipTitle, &property );
    if( property )
    {
        if( *property )
        {
            item.iItem = itemNumber;
            item.pszText = L"Clip Title:";
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            item.iItem = itemNumber;
            item.pszText = property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
        SysFreeString(property);
        property = NULL;
    }

    // Fill in our Clip Artist
    g_pPlayerWindow->m_pMP->GetMediaInfoString( mpClipAuthor, &property );
    if( property )
    {
        if( *property )
        {
            item.iItem = itemNumber;
            item.pszText = L"Clip Artist:";
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            item.iItem = itemNumber;
            item.pszText = property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
        SysFreeString(property);
        property = NULL;
    }

    // Fill in our Clip Description
    g_pPlayerWindow->m_pMP->GetMediaInfoString( mpClipDescription, &property );
    if( property )
    {
        if( *property )
        {
            item.iItem = itemNumber;
            item.pszText = L"Clip Album:"; // The mpClipDescription maps to IAMMediaContent internally.  On CE.NET 4.2, we override
                                        // the "description" field to be Album information (from ID3 or ASF metadata).  So
                                        // let's call this what it usually is - Clip Album, not Clip Description.
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            item.iItem = itemNumber;
            item.pszText = property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
        SysFreeString(property);
        property = NULL;
    }

    // Fill in our Clip Copyright
    g_pPlayerWindow->m_pMP->GetMediaInfoString( mpClipCopyright, &property );
    if( property )
    {
        if( *property )
        {
            item.iItem = itemNumber;
            item.pszText = L"Clip Copyright:";
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            item.iItem = itemNumber;
            item.pszText = property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
        SysFreeString(property);
        property = NULL;
    }

    g_pPlayerWindow->m_pMP->get_FileName( &property );
    if( property )
    {
        if( *property )
        {
            // Fill in our filename
            item.iItem = itemNumber;
            item.pszText = L"Filename:";
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;

            TCHAR *slash = wcsrchr( property, L'\\' );
            item.iItem = itemNumber;
            item.pszText = slash ? ++slash : property;
            if( ListView_InsertItem( m_hListView, &item ) != -1 )
                itemNumber++;

            if (GetTextExtentExPoint(hdc, item.pszText, _tcslen(item.pszText), 0, NULL, NULL, &size)
                && size.cx > cx)
                cx = size.cx;
        }
    }
    // Fill in our duration
    double duration = 0.0;
    VARIANT_BOOL fDurationValid;

    g_pPlayerWindow->m_pMP->get_Duration( &duration );
   	g_pPlayerWindow->m_pMP->get_IsDurationValid(&fDurationValid);

    if( fDurationValid && duration != 0.0 )
    {
        WCHAR durationText[10] = L"";
        Time2String( duration, durationText, 10, FALSE, FALSE, L":", L"." );

        item.iItem = itemNumber;
        item.pszText = L"Duration:";
        if( ListView_InsertItem( m_hListView, &item ) != -1 )
            itemNumber++;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -