1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,mmsystem, ComCtrls, ExtCtrls, MPlayer;
type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; Label2: TLabel; Button2: TButton; Edit1: TEdit; Button3: TButton; TrackBar1: TTrackBar; Timer1: TTimer; Button4: TButton; OpenDialog1: TOpenDialog; Button5: TButton; Label3: TLabel; Button6: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button4Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); private public end;
var Form1: TForm1; x,y,tr:integer; str:char;
implementation
{$R *.dfm} procedure GetVolume(var volL, volR: Word); var hWO: HWAVEOUT; waveF: TWAVEFORMATEX; vol: DWORD; begin volL:= 0; volR:= 0; FillChar(waveF, SizeOf(waveF), 0); waveOutOpen(@hWO, WAVE_MAPPER, @waveF, 0, 0, 0); waveOutGetVolume(hWO, @vol); volL:= vol and $FFFF; volR:= vol shr 16; waveOutClose(hWO); end;
procedure SetVolume(const volL, volR: Word); var hWO: HWAVEOUT; waveF: TWAVEFORMATEX; vol: DWORD; begin FillChar(waveF, SizeOf(waveF), 0); waveOutOpen(@hWO, WAVE_MAPPER, @waveF, 0, 0, 0); vol:= volL + volR shl 16; waveOutSetVolume(hWO, vol); waveOutClose(hWO); end;
procedure TForm1.Button1Click(Sender: TObject); var VolLi, VolRe: Word; begin GetVolume(VolLi,VolRe);
Label1.Caption:=IntToStr(VolLi); Label2.Caption:=IntToStr(VolRe); end;
procedure TForm1.Button2Click(Sender: TObject); begin x:= strtoint(edit1.text); setVolume(x,x);
end;
procedure TForm1.Button3Click(Sender: TObject); begin SndPlaySound( Pchar(opendialog1.filename), SND_ASYNC ); end;
procedure TForm1.Timer1Timer(Sender: TObject); begin if trackbar1.position = 0 then x:= 0; if trackbar1.position = 1 then x:= 10000; if trackbar1.position = 2 then x:= 20000; if trackbar1.position = 3 then x:= 30000; if trackbar1.position = 4 then x:= 40000; if trackbar1.position = 5 then x:= 50000; if trackbar1.position = 6 then x:= 60000; if trackbar1.position = 7 then x:= 65000; setVolume(x,x); end;
procedure TForm1.Button4Click(Sender: TObject); begin if y = 0 then begin tr:=trackbar1.position; trackbar1.Position:=0; y:=1; end else begin trackbar1.position:=tr; y:=0; end; end;
procedure TForm1.FormCreate(Sender: TObject); begin y:=0; trackbar1.position:=4; end;
procedure TForm1.Button5Click(Sender: TObject); var text:textfile; begin if opendialog1.execute then begin if fileexists(opendialog1.FileName) then begin label3.caption:=(opendialog1.FileName);
end; end; end;
procedure TForm1.Button6Click(Sender: TObject); begin sndPlaySound(nil,0); end;
end. |