Unable to set the volume on a specfied Multimedia control 
Author Message
 Unable to set the volume on a specfied Multimedia control

I'm having a problem controlling the volume of specific audio files. Here's
the background.

I am using the Multimedia control to play audio files. This seems to work
OK.
For reference, here is the code (with error handling removed):

   Public PlayerControl As MCI.MMControl
   PlayerControl = New MCI.MMControl()
   PlayerControl.FileName = SoundFileName  'Tell it which sound file to play
   PlayerControl.Notify = False            'Don't notify us when the sound
is done playing (optional)
   PlayerControl.Command = "Open"          'Open the sound file for playing
(required)
   'If Wait=True, wait until done playing before continuing execution
(optional).
   'If Wait=False, begin playing sound file and continue with execution.
   PlayerControl.Wait = False
   PlayerControl.Command = "Play"          'Play the sound (required)

Since this multimedia control can't control its own volume, an API call must
be
made to do so. The .NET declaration for this is as follows:

   Public Declare Function waveOutSetVolume Lib "winmm.dll" _
      (ByVal uDeviceID As Integer, ByVal dwVolume As Integer) As Integer

Basically, argument uDeviceId is the Id of the audio device, and dwVolume is
the
volume setting. Calling the function as follows works:

   Dim Result as integer = waveOutSetVolume(0, &H7FF)

and reduces the volume to one-half its previous value. I have no problem
with the
volume argument.

However, here argument uDeviceID is set to 0, meaning all devices. But I
only
want to control this particular multimedia object. The API documentation
says
that this can be either "a device identifier or a handle to the waveform
output
device". Hence, with respect to the above multimedia control, this can be
set
to either:

 PlayerControl.DeviceID
 PlayerControl.hWnd

But the PlayerControl.DeviceID always returns 1 or 2, and this causes
waveOutSetVolume to return an error code of 2 (instead of the success of 0).
On the other hand, PlayerControl.hWnd always returns zero, which doesn't
seem right.

So I'm stuck. It appears that the Multimedia control is at fault under .NET
since
it doesn't appear to return a proper DeviceId or hWnd.

Am I missing something, or is there a workaround?

Don Peters



Wed, 17 Aug 2005 02:05:01 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Controling the volume with a multimedia control

2. Volume control via Multimedia API calls

3. Multimedia Volume level

4. Master Volume Control Setting - how to retrieve?

5. Unable to set control property (a second time) at runtime

6. VB Multimedia Adventure Set book

7. VB Multimedia Adventure Set!

8. Multimedia control question (MCI Control)

9. Setting Volume

10. Setting VOLUME of PC SPEAKER?

11. Setting VOLUME of PC SPEAKER?

12. How can I set the volume?

 

 
Powered by phpBB® Forum Software