Re: TMediaPlayerPosted by webmaster Guido on October 02, 2002 at 03:15:59: In Reply to: TMediaPlayer posted by p12258 Jodell Bumatai on September 26, 2002 at 06:26:04:
: I have followed a tutorial for using the TMediaPlayer component with Delphi 5 STD. var WaveCaps: TWAVEOUTCAPS; Volume: DWord; VolumeLeft, VolumeRight: Word; // 0xFFFF is full volume, 0x0000 is silence procedure TForm1.GetVolume; begin // Retrieve the capabilities of waveform-audio output device "WAVE_MAPPER". // Structure WaveCaps is filled with info about the capabilities of the device. WaveOutGetDevCaps(WAVE_MAPPER, @WaveCaps, SizeOf(WaveCaps)); // Check if volume control is supported if (WaveCaps.dwSupport and WAVECAPS_VOLUME) = WAVECAPS_VOLUME then begin // Retrieve the current volume level WaveOutGetVolume(WAVE_MAPPER, @Volume); VolumeLeft := LoWord(Volume); VolumeRight := HiWord(Volume); end else ShowMessage('Volume control not supported'); end; procedure TForm1.SetVolume; begin WaveOutGetDevCaps(WAVE_MAPPER, @WaveCaps, SizeOf(WaveCaps)); if (WaveCaps.dwSupport and WAVECAPS_VOLUME) = WAVECAPS_VOLUME then begin // Combine left- and right-volume into a double word value Volume := VolumeLeft or (VolumeRight shl 16); WaveOutSetVolume(WAVE_MAPPER, Volume); end else ShowMessage('Volume control not supported'); end; How to use these functions? Here's an example for showing the volume in two labels: GetVolume; labelLeft.Caption := IntToStr(VolumeLeft); labelRight.Caption := IntToStr(VolumeRight); Setting the volume with the values that were entered in two Edit-boxes is like this: VolumeLeft := StrToInt(Edit1.Text); // max is 65535 VolumeRight := StrToInt(Edit2.Text); // max is 65535Starting on this basis, you can design a nicer interface using slider-controls (TTrackbar component): just one for the volume, left and right treated equally, or two sliders, using the first one for the volume and the other one for the left/right balance. But that's "just math" ;-)
|
|