Thread View: borland.public.cppbuilder.multimedia
1 messages
1 total messages
Started by Avatar.Viper
Mon, 26 Jun 2006 14:28
Problem playing mp3 with directshow
Author: Avatar.Viper
Date: Mon, 26 Jun 2006 14:28
Date: Mon, 26 Jun 2006 14:28
101 lines
4046 bytes
4046 bytes
I have use this code below to play MP3 files provided by one of the
user here:
#include <dshow.h>
IGraphBuilder *Graph = NULL;
IMediaControl *Control = NULL;
IMediaSeeking *Seeker = NULL
__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{
::CoInitialize(NULL);
if( SUCCEEDED(::CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (LPVOID*)&Graph)) )
{
Graph->QueryInterface(IID_IMediaControl,
(LPVOID*)&Control);
Graph->QueryInterface(IID_IMediaSeeking, (LPVOID*)&Seeker);
}
}
__fastcall TForm1::~TForm1()
{
if( Seeker )
Seeker->Release();
if( Control )
{
Control->Stop();
Control->Release();
}
if( Graph )
Graph->Release();
::CoUninitialize();
}
void __fastcall TForm1::OpenFileButtonClick(TObject *Sender)
{
if( Graph && Control )
{
if( OpenDialog1->Execute() )
{
Control->Stop();
RemoveFilters();
Graph->RenderFile(WideString(OpenDialog1->FileName),
NULL);
}
}
}
void __fastcall TForm1::PlayFileButtonClick(TObject *Sender)
{
if( Control && Seeker )
{
REFERENCE_TIME rt = 0;
if( SUCCEEDED(Seeker->SetPositions(&rt,
AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning)) )
Control->Run();
}
}
void __fastcall TForm1::RemoveFilters()
{
IEnumFilters* pEnumFilters = NULL;
IBaseFilter* pFilter = NULL;
IEnumPins* pEnumPins = NULL;
IPin* pPin = NULL;
IPin* pOtherPin = NULL;
if( SUCCEEDED(Graph->EnumFilters(&pEnumFilters)) )
{
while( pEnumFilters->Next(1, &pFilter, NULL) == S_OK )
{
if( SUCCEEDED(pFilter->EnumPins(&pEnumPins)) )
{
while( pEnumPins->Next(1, &pPin, NULL) == S_OK )
{
if( pPin->ConnectedTo(&pOtherPin) == S_OK )
{
Graph->Disconnect(pPin);
Graph->Disconnect(pOtherPin);
pOtherPin->Release();
}
pPin->Release();
}
pEnumPins->Release();
}
Graph->RemoveFilter(pFilter);
pFilter->Release();
pEnumFilters->Reset();
}
pEnumFilters->Release();
}
}
but i found out that some of my mp3 files cannot be played but can be
played on WMP. Anyone has some ideas what is going on? Using WinXP SP2
Directx 9.0c. thx.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads