🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #48

Problem playing mp3 with directshow

#48
From: Avatar.Viper
Date: Mon, 26 Jun 2006 14:28
101 lines
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.
Technical Details
Message-ID: <1151332131.457168.127160@u72g2000cwu.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!u72g2000cwu.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,adf9534d0d4c49de,start
X-Google-Attributes: gid10d0fc,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!u72g2000cwu.googlegroups.com!not-for-mail
From: Avatar.Viper@gmail.com
Newsgroups: borland.public.cppbuilder.multimedia
Subject: Problem playing mp3 with directshow
Date: 26 Jun 2006 07:28:51 -0700
Organization: http://groups.google.com
Lines: 102
Message-ID: <1151332131.457168.127160@u72g2000cwu.googlegroups.com>
NNTP-Posting-Host: 202.156.6.4
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1151332135 19202 127.0.0.1 (26 Jun 2006 14:28:55 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 26 Jun 2006 14:28:55 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: u72g2000cwu.googlegroups.com; posting-host=202.156.6.4;
   posting-account=LW5hLQ0AAAA5xVGdij8NhQ9RX3q35aij