Delphi Media Player Volume Control

I have two mediaplayers in one form, how to get low volume in one mediaplayer and still high in other? Help me
Muhamad PurwantoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
Are you using TmediaPlayer components?
If so you coud do that using MCI

This is a part of code that I use for a little mp3 player application

First the audio control procedure
uses MMSystem;
procedure SetMPVolume(MP : TMediaPlayer; Volume : Integer);
const
  MCI_SETAUDIO               = $0873;
  MCI_DGV_SETAUDIO_VOLUME    = $4002;
  MCI_DGV_SETAUDIO_ITEM      = $00800000;
  MCI_DGV_SETAUDIO_VALUE     = $01000000;

Type
  MCI_DGV_SETAUDIO_PARMS = record
   dwCallback : DWORD;
   dwItem     : DWORd;
   dwValue : DWORD;
   dwOver : DWORD;
   lpstrAlgorithm : PChar;
   lpstrQuality : PChar;
  end;

var
  p       : MCI_DGV_SETAUDIO_PARMS;

begin
   { Volume: 0 - 1000 }
   p.dwCallback := 0;
   p.dwItem := MCI_DGV_SETAUDIO_VOLUME;
   p.dwValue := Volume;
   p.dwOver := 0;
   p.lpstrAlgorithm := nil;
   p.lpstrQuality := nil;
   mciSendCommand(MP.DeviceID, MCI_SETAUDIO,
    MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, Cardinal(@p));
end;

Open in new window

Then, having 2 TMediaPlayer and 2 TTrackBar on the form, set the properties MAX of the both TTrackBar to 1000 (Min to 0) and change the volume of the 2 MP as follows

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
  SetMPVolume(MediaPlayer1, TrackBar1.Position);
end;

procedure TForm1.TrackBar2Change(Sender: TObject);
begin
  SetMPVolume(MediaPlayer2, TrackBar2.Position);
end;

Open in new window

It's just a point of start. Hope it helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Muhamad PurwantoAuthor Commented:
It works for me, thanks a lot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.