Home
Facebook
Twitter
Google+
RSS Feeds
Sebatas Catatan
≡
Navigation
Home
Tentang Blog
Daftar Isi
Home
»
Delphi
»
Open Source
»
Pemrograman
»
Tips n Tricks
»
Mengatur Volume TMediaplayer Delphi
Mengatur Volume TMediaplayer Delphi
Posted by
Ghozali Muslim
Mengatur volume pada komponen TMediaPlayer bawaan delphi
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, MPlayer, MMSystem;
//--- tambah constanta disini untuk mengatur volume
const
// ---- buat loading volume ----
MCI_SETAUDIO = $0873;
MCI_DGV_SETAUDIO_VOLUME = $4002;
MCI_DGV_SETAUDIO_ITEM = $00800000;
MCI_DGV_SETAUDIO_VALUE = $01000000;
MCI_DGV_STATUS_VOLUME = $4019;
type
TForm1 = class(TForm)
Button1: TButton;
TrackBar1: TTrackBar;
Label1: TLabel;
MediaPlayer1: TMediaPlayer;
OpenDialog1: TOpenDialog;
StatusBar1: TStatusBar;
procedure FormCreate(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// tambahkan " type " untuk atur volume
type
MCI_DGV_SETAUDIO_PARMS = record // volume
dwCallback: DWORD;
dwItem: DWORD;
dwValue: DWORD;
dwOver: DWORD;
lpstrAlgorithm: PChar;
lpstrQuality: PChar;
end;
// tambahkan " type " untuk atur volume
type
MCI_STATUS_PARMS = record // volume
dwCallback: DWORD;
dwReturn: DWORD;
dwItem: DWORD;
dwTrack: DWORD;
end;
// prosedur set volume
procedure MPSetVolume(MP:TMediaPlayer;Volume:Integer) ;
var
p: MCI_DGV_SETAUDIO_PARMS;
begin
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;
// dapatkan Volume, range 0 - 1000
function MPGetVolume(MP: TMediaPlayer): Integer;
var
p: MCI_STATUS_PARMS;
begin
p.dwCallback := 0;
p.dwItem := MCI_DGV_STATUS_VOLUME;
mciSendCommand(MP.DeviceID, MCI_STATUS, MCI_STATUS_ITEM, Cardinal(@p)) ;
Result := p.dwReturn;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption :='0%';
TrackBar1.Position:=400;
MPGetVolume(MediaPlayer1);
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
var
i:real;
begin
i:=int(TrackBar1.Position/TrackBar1.Max*100);
Label1.Caption:=floattostr(i)+'%';
MPSetVolume(MediaPlayer1,TrackBar1.Position);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
StatusBar1.SimpleText:=OpenDialog1.FileName;
MediaPlayer1.Close;
MediaPlayer1.FileName:=OpenDialog1.FileName;
MediaPlayer1.Open;
end;
end;
end.
Hasil Screenshot :
Download Source Code
DISINI
Tweet
Please FOLLOW and JOIN to get update!
Cool Social Media Sharing Touch Me Widget by
Blogger Widgets
Blog,
Updated at:
9:35 AM
0 comments:
Post a Comment
Newer Post
Older Post
Home
Popular Posts
Menampilkan Bilangan Genap Ganjil dan Prima dengan Delphi
Konversi Text ke ASCII, HEXA, BINER, OCTAL
Menggunakan Fast Report Secara Runtime
Koneksi Database Interbase / Firebird dengan Delphi 7
Membuat Tabel Pada Interbase / Firebird via IBExpert
Categories
Database
Delphi
Firebird
IBExpert
Interbase
Jaringan
Lazarus
MySQL
Network
Open Source
Pemrograman
RDBMS
Tips n Tricks
Archives
►
2014
(4)
►
June
(1)
►
March
(1)
►
February
(1)
►
January
(1)
▼
2013
(32)
►
December
(1)
►
November
(1)
►
October
(1)
►
September
(2)
▼
August
(2)
Mengatur Volume TMediaplayer Delphi
Menghitung Umur Delphi
►
July
(5)
►
June
(2)
►
May
(2)
►
April
(4)
►
March
(8)
►
February
(1)
►
January
(3)
►
2012
(11)
►
December
(11)
0 comments:
Post a Comment