Author: Tomas Rutkauskas How to adjust the volume on TMediaPlayer Answer: 1 unit MpVolume; 2 3 interface 4 5 uses Windows, MPlayer; 6 7 const 8 MCI_SETAUDIO = $0873; 9 MCI_DGV_SETAUDIO_VOLUME = $4002; 10 MCI_DGV_SETAUDIO_ITEM = $00800000; 11 MCI_DGV_SETAUDIO_VALUE = $01000000; 12 13 MCI_DGV_STATUS_VOLUME = $4019; 14 15 type 16 MCI_DGV_SETAUDIO_PARMS = record 17 dwCallback: DWORD; 18 dwItem: DWORd; 19 dwValue: DWORD; 20 dwOver: DWORD; 21 lpstrAlgorithm: PChar; 22 lpstrQuality: PChar; 23 end; 24 25 type 26 MCI_STATUS_PARMS = record 27 dwCallback: DWORD; 28 dwReturn: DWORD; 29 dwItem: DWORD; 30 dwTrack: DWORD; 31 end; 32 33 //Remember to add the name of your form to the procedures 34 function GetMPVolume(MP: TMediaPlayer): Integer; 35 procedure SetMPVolume(MP: TMediaPlayer; Volume: Integer); 36 37 implementation 38 39 uses mmsystem; 40 41 function GetMPVolume(MP: TMediaPlayer): Integer; 42 var 43 p: MCI_STATUS_PARMS; 44 begin 45 p.dwCallback := 0; 46 p.dwItem := MCI_DGV_STATUS_VOLUME; 47 mciSendCommand(MP.DeviceID, MCI_STATUS, MCI_STATUS_ITEM, Cardinal(@p)); 48 Result := p.dwReturn; 49 { Volume: 0 - 1000 } 50 end; 51 52 procedure SetMPVolume(MP: TMediaPlayer; Volume: Integer); 53 var 54 p: MCI_DGV_SETAUDIO_PARMS; 55 begin 56 { Volume: 0 - 1000 } 57 p.dwCallback := 0; 58 p.dwItem := MCI_DGV_SETAUDIO_VOLUME; 59 p.dwValue := Volume; 60 p.dwOver := 0; 61 p.lpstrAlgorithm := nil; 62 p.lpstrQuality := nil; 63 mciSendCommand(MP.DeviceID, MCI_SETAUDIO, 64 MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, Cardinal(@p)); 65 end; 66 67 end.