Click here to Skip to main content
15,903,385 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Window Media Control Pin
Anonymous3-Feb-04 16:31
Anonymous3-Feb-04 16:31 
GeneralRe: Window Media Control Pin
don7cry3-Feb-04 17:06
don7cry3-Feb-04 17:06 
GeneralRe: Window Media Control Pin
sstoyan3-Feb-04 21:54
sstoyan3-Feb-04 21:54 
Questionhow to play audio file over Internet Pin
don7cry2-Feb-04 22:35
don7cry2-Feb-04 22:35 
GeneralGet Product Version Pin
ctopmep2-Feb-04 22:33
ctopmep2-Feb-04 22:33 
GeneralCoInitializeEx & SOAP Pin
Victor19782-Feb-04 22:06
Victor19782-Feb-04 22:06 
Generalflock question Pin
alex.barylski2-Feb-04 22:04
alex.barylski2-Feb-04 22:04 
QuestionAbout the WAV to WMA of audio ? Pin
zhaopzhi2-Feb-04 21:42
zhaopzhi2-Feb-04 21:42 
I wrote a code of WAV(C:\\InputFile.wav) to WMA(C:\\OutputFile.wma) of the audio,but it was distempered.Please give a help,thank you in advance.
The following is my code:

// Include libraries.<br />
#include <windows.h><br />
#include <atlbase.h><br />
#include <comdef.h><br />
#include "D:\WMSDK\WMEncSDK9\include\wmencode.h"<br />
#include <conio.h> // for kbhit()<br />
<br />
void main()<br />
{<br />
    // Declare variables.<br />
    HRESULT hr;<br />
    IWMEncoder* pEncoder;<br />
    IWMEncSourceGroupCollection* pSrcGrpColl;<br />
    IWMEncSourceGroup* pSrcGrp;<br />
    IWMEncSource* pSrc;<br />
    IWMEncVideoSource* pSrcVid;<br />
	IWMEncAudioSource* pSrcAud;<br />
    IPropertyBag* pPropertyBag;<br />
    IWMEncProfileCollection* pProColl;<br />
    IWMEncProfile* pPro;<br />
    IWMEncFile* pFile;<br />
    IWMEncAttributes* pAttr;<br />
    IWMEncDisplayInfo* pDispInfo;<br />
    CComBSTR bstrName = NULL;<br />
    long lCount;<br />
    int i;<br />
<br />
    // Initialize the COM library and retrieve a pointer to an IWMEncoder interface.<br />
    hr = CoInitialize(NULL);<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = CoCreateInstance(CLSID_WMEncoder,<br />
            NULL,<br />
            CLSCTX_INPROC_SERVER,<br />
            IID_IWMEncoder,<br />
            (void**) &pEncoder);<br />
    }<br />
<br />
    // Retrieve the source group collection.<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);<br />
    }<br />
<br />
    // Add a source group to the collection.<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pSrcGrpColl->Add(CComBSTR("SG_1"), &pSrcGrp);<br />
    }<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
		 hr = pSrcGrp->AddSource(WMENC_AUDIO, &pSrc);<br />
    }<br />
<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pSrc->QueryInterface(IID_IWMEncAudioSource, (void**)&pSrcAud);<br />
    }<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
		hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.wav"));<br />
    }<br />
<br />
    // Specify a file object in which to save encoded content.<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pEncoder->get_File(&pFile);<br />
    }<br />
    if ( SUCCEEDED( hr ) )									  <br />
    {<br />
        hr = pFile->put_LocalFileName(CComBSTR("C:\\OutputFile.wma"));<br />
    }<br />
<br />
    // Retrieve a pointer to the property bag.<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pSrcAud->QueryInterface(IID_IPropertyBag, (void**)&pPropertyBag);<br />
    }<br />
    // Choose a profile from the collection.<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pEncoder->get_ProfileCollection(&pProColl);<br />
    }<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pProColl->get_Count(&lCount);<br />
    }<br />
    for (i=0; i<lCount; i++)<br />
    {<br />
        if ( SUCCEEDED( hr ) )<br />
        {<br />
            hr = pProColl->Item(i, &pPro);<br />
        }<br />
        if ( SUCCEEDED( hr ) )<br />
        {<br />
            hr = pPro->get_Name(&bstrName);<br />
        }<br />
        if (_wcsicmp(bstrName,CComBSTR("Windows Media Video 8 for Local Area Network (384 Kbps)"))==0)<br />
        {<br />
            // Set the profile in the source group.<br />
            if ( SUCCEEDED( hr ) )<br />
            {<br />
                hr = pSrcGrp->put_Profile(CComVariant(pPro));<br />
            }<br />
            break;<br />
        }<br />
    }<br />
<br />
    // Start the encoding process.<br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pEncoder->PrepareToEncode(VARIANT_TRUE);<br />
    }  <br />
    if ( SUCCEEDED( hr ) )<br />
    {<br />
        hr = pEncoder->Start();<br />
        // Keep the console window open.<br />
        printf("When encoding stops, press a key to close the console window.");<br />
<br />
        // Stop the encoding process.<br />
        if ( SUCCEEDED( hr ) )<br />
        {<br />
            // Wait for a key press.<br />
            while(!kbhit())<br />
               _asm nop;<br />
<br />
            hr = pEncoder->Stop();<br />
        }<br />
    }<br />
<br />
    // Release pointers.<br />
    if ( pPropertyBag )<br />
    {<br />
        pPropertyBag->Release();<br />
        pPropertyBag = NULL;<br />
    }<br />
    if ( pSrcGrpColl )<br />
    {<br />
        pSrcGrpColl->Release();<br />
        pSrcGrpColl = NULL;<br />
    }<br />
    if ( pSrcGrp )<br />
    {<br />
        pSrcGrp->Release();<br />
        pSrcGrp = NULL;<br />
    }<br />
    if ( pProColl )<br />
    {<br />
        pProColl->Release();<br />
        pProColl = NULL;<br />
    }<br />
<br />
    if ( pPro )<br />
    {<br />
        pPro->Release();<br />
        pPro = NULL;<br />
    } <br />
    if ( pFile )<br />
    {<br />
        pFile->Release();<br />
        pFile = NULL;<br />
    }<br />
    if ( pSrcAud )<br />
    {<br />
        pSrcAud->Release();<br />
        pSrcAud = NULL;<br />
    }<br />
    if ( pSrcVid )<br />
    {<br />
        pSrcVid->Release();<br />
        pSrcVid = NULL;<br />
    }<br />
    if ( pSrc )<br />
    {<br />
        pSrc->Release();<br />
        pSrc = NULL;<br />
    }<br />
    if ( pAttr )<br />
    {<br />
        pAttr->Release();<br />
        pAttr = NULL;<br />
    }<br />
<br />
    if ( pDispInfo )<br />
    {<br />
        pDispInfo->Release();<br />
        pDispInfo = NULL;<br />
    }<br />
    if ( pEncoder )<br />
    {<br />
        pEncoder->Release();<br />
        pEncoder = NULL;<br />
    }<br />
}


Rap off for you,for me,for our human.
GeneralAutocomplete Pin
Mike Mehan2-Feb-04 21:32
sussMike Mehan2-Feb-04 21:32 
Generalanimated buttons Pin
amit sebiz2-Feb-04 20:25
amit sebiz2-Feb-04 20:25 
GeneralRe: animated buttons Pin
sps-itsec462-Feb-04 22:04
sps-itsec462-Feb-04 22:04 
GeneralDoubt ! Creating Service! Pin
Ilamparithi2-Feb-04 19:48
Ilamparithi2-Feb-04 19:48 
QuestionLinking object file ? Pin
CarteBlanche2-Feb-04 19:11
CarteBlanche2-Feb-04 19:11 
AnswerRe: Linking object file ? Pin
CarteBlanche2-Feb-04 19:26
CarteBlanche2-Feb-04 19:26 
Questionconvert double to Integer????????? Pin
wow99992-Feb-04 18:56
wow99992-Feb-04 18:56 
AnswerRe: convert double to Integer????????? Pin
alex.barylski2-Feb-04 21:57
alex.barylski2-Feb-04 21:57 
AnswerRe: convert double to Integer????????? Pin
jhwurmbach2-Feb-04 23:03
jhwurmbach2-Feb-04 23:03 
Questionhow can i find sqlcli1.h? Pin
google732-Feb-04 18:05
google732-Feb-04 18:05 
AnswerRe: how can i find sqlcli1.h? Pin
Roger Wright2-Feb-04 18:22
professionalRoger Wright2-Feb-04 18:22 
GeneralRe: how can i find sqlcli1.h? Pin
google732-Feb-04 18:47
google732-Feb-04 18:47 
QuestionProgram not responding? Pin
Xzyx987X2-Feb-04 17:46
Xzyx987X2-Feb-04 17:46 
Generalansi/iso C++ compiler Pin
Anonymous2-Feb-04 17:33
Anonymous2-Feb-04 17:33 
GeneralRe: ansi/iso C++ compiler Pin
valikac2-Feb-04 17:35
valikac2-Feb-04 17:35 
GeneralRe: ansi/iso C++ compiler Pin
Joe Woodbury2-Feb-04 18:23
professionalJoe Woodbury2-Feb-04 18:23 
GeneralRe: ansi/iso C++ compiler Pin
jhwurmbach2-Feb-04 23:08
jhwurmbach2-Feb-04 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.