Re: Some help for newbie from gurus - Multiple Sources on a single track

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Apurva Lawale" <apudeepa@xxxxxxxxxxxxxx> wrote>
> I am trying to add multiple media to the same track.
>
> Like:
>
> --------------------
> Media1 | Media2
> -------------------
>
> The quick and dirty figure above shows 1 Track with 2 Media files back to
> back.
>
>
> Well the code that i am trying out is :
>
>
> pTL->CreateEmptyNode(&pSourceObj, TIMELINE_MAJOR_TYPE_SOURCE);
> pSourceObj->QueryInterface(IID_IAMTimelineSrc, (void **)&pSource);
>
> // Set the times and the file name.
> pSourceObj->SetStartStop(0,25*10000000);
> BSTR bstrFile = SysAllocString(OLESTR("C:\\1.avi"));
> pSource->SetMediaName(bstrFile);
> SysFreeString(bstrFile);
> pSource->SetMediaTimes(0,24*10000000);
> pTrack->SrcAdd(pSourceObj);
> bstrFile = SysAllocString(OLESTR("C:\\1.jpg"));
> pSource->SetMediaName(bstrFile);
> SysFreeString(bstrFile);
> pSource->SetMediaTimes(0,1*10000000);
> pTrack->SrcAdd(pSourceObj);
>
> pSourceObj->Release();
> pSource->Release();
> pTrack->Release();
>
>
> The above code only shows me 1.jpg and it does not show me 1.avi. It means
> it only shows me that last media file. I am sure this is something simple
> (at least for the gurus out here), I can't figure it out though. Please
tell
> me what am I doing wrong.
>

AFAIK you must release the IAMTimelineSrc and IAMTimelineObj
interfaces(pSource and pSourceObj) before you use them in a second clip.
Something like this;

pTL->CreateEmptyNode(&pSourceObj, TIMELINE_MAJOR_TYPE_SOURCE);
pSourceObj->QueryInterface(IID_IAMTimelineSrc, (void **)&pSource);

// Set the times and the file name.
pSourceObj->SetStartStop(0,25*10000000);
BSTR bstrFile = SysAllocString(OLESTR("C:\\1.avi"));
pSource->SetMediaName(bstrFile);
SysFreeString(bstrFile);
pSource->SetMediaTimes(0,24*10000000);
pTrack->SrcAdd(pSourceObj);

pSourceObj->Release();
pSource->Release();

pTL->CreateEmptyNode(&pSourceObj, TIMELINE_MAJOR_TYPE_SOURCE);
pSourceObj->QueryInterface(IID_IAMTimelineSrc, (void **)&pSource);

bstrFile = SysAllocString(OLESTR("C:\\1.jpg"));
pSource->SetMediaName(bstrFile);
SysFreeString(bstrFile);
pSource->SetMediaTimes(0,1*10000000);
pTrack->SrcAdd(pSourceObj);

pSourceObj->Release();
pSource->Release();
pTrack->Release();


Seyfullah.


.



Relevant Pages