Thread View: borland.public.cppbuilder.multimedia
3 messages
3 total messages
Started by Ron Sawyer
Thu, 04 Dec 2003 22:48
MP3 VCL Player
Author: Ron Sawyer
Date: Thu, 04 Dec 2003 22:48
Date: Thu, 04 Dec 2003 22:48
1 lines
978 bytes
978 bytes
Does anyone know of an MP3 Player VCL? Does Direct Sound play MP3?
Re: MP3 VCL Player
Author: Rodrigo G�mez
Date: Sat, 06 Dec 2003 17:25
Date: Sat, 06 Dec 2003 17:25
20 lines
1926 bytes
1926 bytes
You can try MMTools, they have a component to encode and decode MP3. If you're reffering that DirectSound directly supports or offers a kind of player for MP3 files, I don't know. But IIRC, Microsoft deploys with their OS (at least Windows XP and up, maybe Windows 2000) a codec for MP3, that I assume you should be able to use inside DirectSound. This has the BIG advantage that Microsoft already paid for the royalities of using this codec, as long as the OS has it by default. Otherwise (doing yourself your codec, or using for example the MMTools one) you will have to pay big bucks for use it in your apps. That's why I always recomend OggVorbis :-) (www.vorbis.com) -- Rodrigo G�mez "Ron Sawyer" <rsawyer8128@aol.com> escribi� en el mensaje news:3FCFB9A0.F2709BA@aol.com... > Does anyone know of an MP3 Player VCL? Does Direct Sound play MP3?
Re: MP3 VCL Player
Author: Mark Jacobs
Date: Mon, 05 Apr 2004 14:47
Date: Mon, 05 Apr 2004 14:47
174 lines
8255 bytes
8255 bytes
MediaPlayer will use codecs installed by the OS to play back MP3s. I had no problem opening all varieties of
multimedia files on my PC with a bog-standard MediaPlayer component. The only things it would not play were
MOVs (Quicktime) RMs (Real Media) and OGG (Vorbis) files. So, why do you need to circumvent a perfectly good
component? Here is the source code for the mm player I wrote ( exe free for download at
http://www.jacobsm.com/mjplayer.exe ) :-
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Main.h"
//---------------------------------------------------------------------------
#pragma link "CSPIN"
#pragma link "zBtn2"
#pragma link "zPanel"
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
cmdl=false; plying=false; inply=false; ckt=-1; Top=Screen->Height-Height*2;
plist=new TStringList(); plems=(int *)malloc(1*sizeof(int)); nodel=false;
}
//----------------------------------------------------------------------------
void __fastcall TMainForm::FileOpen(TObject *Sender)
{
int ii;
if (plying) return;
if (!cmdl)
{
if (!OpenDialog->Execute()) return;
plist->Assign(OpenDialog->Files); plist->Sorted=true;
}
cmdl=false; plist->SaveToFile(ckf); ckt=FileAge(ckf);
plems=(int *)realloc(plems,plist->Count*sizeof(int)); if (!plems) return;
for (ii=0;ii<plist->Count;++ii) plems[ii]=ii;
plylst(Sender);
}
//----------------------------------------------------------------------------
void __fastcall TMainForm::dolabs()
{
static AnsiString ollb2="",ollb3=""; AnsiString nllb2="",nllb3=""; bool doit=false;
if (MediaPlayer1->FileName.IsEmpty()) return;
int wh2=MediaPlayer1->Position/1000,wh3=MediaPlayer1->Length/1000;
if (wh2>=3600) { nllb2+=AnsiString(wh2/3600)+"h "; wh2%=3600;}
if (wh2>=60) { nllb2+=AnsiString(wh2/60)+"m "; wh2%=60;}
nllb2+=AnsiString(wh2)+"s";
if (wh3>=3600) { nllb3+=AnsiString(wh3/3600)+"h "; wh3%=3600;}
if (wh3>=60) { nllb3+=AnsiString(wh3/60)+"m "; wh3%=60;}
nllb3+=AnsiString(wh3)+"s";
if (ollb2!=nllb2) { Label2->Caption=nllb2; ollb2=nllb2; doit=true;}
if (ollb3!=nllb3) { Label3->Caption=nllb3; ollb3=nllb3; doit=true;}
if (doit) Application->Title=ExtractFileName(MediaPlayer1->FileName)+" "+nllb2+" of "+nllb3;
}
//----------------------------------------------------------------------------
void __fastcall TMainForm::plylst(TObject *Sender)
{
int ii,jj,tsp;
AnsiString sndexts="*.mid*;*.wav;*.mp3;*.mp2;*.wma;*.au;*.aif*;*.asx;*.rmi;*.snd;*.cda";
for (brk=false,jj=0;!brk && jj<plist->Count;++jj)
{
ii=plems[jj]; MediaPlayer1->FileName="";
Caption="MJPlayer "+AnsiString(jj+1)+"/"+AnsiString(plist->Count)+" "+plist->Strings[ii];
MediaPlayer1->FileName=plist->Strings[ii];
try
{
MediaPlayer1->Open();
}
catch (Exception &excp)
{
MediaPlayer1->FileName=""; ShowMessage(excp.Message); continue;
}
MediaPlayer1->TimeFormat=tfMilliseconds; MediaPlayer1->Notify=true;
tsp=max(100,MediaPlayer1->Length/10); zKnob1->Max=tsp; zKnob1->Value=tsp/2; zKnob1Change(Sender);
do
{
inply=true; MediaPlayer1->Play(); plying=true; while (plying) Application->ProcessMessages();
inply=false; if (brk) return;
}
while (CheckBox1->Checked && plist->Count==1);
if (CheckBox1->Checked && jj==plist->Count-1) jj=-1;
}
}
//----------------------------------------------------------------------------
void __fastcall TMainForm::MediaPlayer1Notify(TObject *Sender)
{
if (MediaPlayer1->Position>=MediaPlayer1->Length-1) { Application->Title="MJPlayer"; plying=false;}
}
//----------------------------------------------------------------------------
void __fastcall TMainForm::MediaPlayer1Click(TObject *Sender, TMPBtnType Button, bool &DoDefault)
{
if (plist->Count<1) { DoDefault=false; return;}
if (Button==btStop) { MediaPlayer1->Position=MediaPlayer1->Length; plying=false; brk=true;}
else if (Button==btPause) inply=false;
else if (Button==btPlay)
{
DoDefault=false; if (plying) { inply=true; MediaPlayer1->Play();} else plylst(Sender);
}
else if (Button==btStep)
{
DoDefault=false;
MediaPlayer1->Position=min(MediaPlayer1->Length-1,MediaPlayer1->Position+stp); dolabs();
if (inply) MediaPlayer1->Play();
}
else if (Button==btBack)
{
DoDefault=false;
MediaPlayer1->Position=max(0,MediaPlayer1->Position-stp); dolabs();
if (inply) MediaPlayer1->Play();
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
{
plying=false; brk=true; Application->ProcessMessages(); CanClose=true; delete plist; free(plems);
if (!nodel && FileExists(ckf)) DeleteFile(ckf);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::BitBtn2Click(TObject *Sender)
{
if (plist->Count<1) return;
shuffleintarr(plems,plist->Count);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::zKnob1Change(TObject *Sender)
{
static int olv=-1; int nmns,nscs;
if (olv!=zKnob1->Value)
{
stp=zKnob1->Value; nmns=stp/60000; nscs=stp-nmns*60000;
if (nmns>0) zKnob1->Hint="Step "+AnsiString(nmns)+"m "+AnsiString(nscs/1000)+"s";
else zKnob1->Hint="Step "+mjfmtfl((double)nscs/1000.0)+"s";
Application->HideHint(); Application->ActivateHint(Mouse->CursorPos); olv=stp;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormPaint(TObject *Sender)
{
static bool clld=false;
if (clld) return;
clld=true; ckf=ChangeFileExt(ParamStr(0),".CPLY"); MediaPlayer1->Wait=false;
if (!ParamStr(1).IsEmpty())
{
plist->Text=ParamStr(1);
if (FileExists(ckf)) { plist->SaveToFile(ckf); nodel=true; Timer1->Enabled=true; return;}
OpenDialog->InitialDir=ExtractFilePath(ParamStr(1)); cmdl=true; FileOpen(Sender);
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Timer1Timer(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Timer2Timer(TObject *Sender)
{
if (plist->Count>0) dolabs();
if (FileAge(ckf)!=ckt)
{
if (plying) { MediaPlayer1->Position=MediaPlayer1->Length; plying=false; brk=true;}
else { plist->LoadFromFile(ckf); cmdl=true; FileOpen(Sender);}
}
}
//---------------------------------------------------------------------------
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
markj@criticalremovethisspuriousantispamstuff.co.uk
"Ron Sawyer" <rsawyer8128@aol.com> wrote in message news:3FCFB9A0.F2709BA@aol.com...
> Does anyone know of an MP3 Player VCL? Does Direct Sound play MP3?
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