Results 1 to 17 of 17

Thread: [RESOLVED] Volume Control

  1. #1

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Resolved [RESOLVED] Volume Control

    I am writing my own mp3 player. I have a reference to Active Movie control type library and MS Shell Controls and Automation. To play the files I use
    Code:
    Private FilgraphManager   As QuartzTypeLib.FilgraphManager           Private IMediaEventEx     As QuartzTypeLib.IMediaEventEx
    I want to add a volume control to the form. Can someone tell me what control, or reference, etc to use?

    Thanks

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,867

    Re: Volume Control

    Which control? Maybe a Slider, Updown, or some wacky custom "twistable knob" control.

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,664

    Re: Volume Control

    Or just a Picturebox, depending on where inside the PB you clicked, you paint that VLC-Triangle-Thingy adjusting the Volume at the same time
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  4. #4

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Volume Control

    Nothing fancy. A slider, or two buttons, 1 up and 1 down. I would put the relative volume number in between.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    8,048
    Sam I am (as well as Confused at times).

  6. #6

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Volume Control

    Thank you all for your examples. I will evaluate and try to incorporate one of then into my code.

    The main point, I think, is that however you are playing the the mp3 files has no bearing on the connecting to the system volume control.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,867

    Re: Volume Control

    Why would the playback volume change the system volume? You aren't making any sense.

    What are you trying to ask here anyway? Sounds like you haven't read up on IBasicAudio.Volume yet or something.

  8. #8

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Volume Control

    I reviewed IBasicAudio.Volume and the program crashes on the statement
    Code:
     iAudio.Volume = Me.slVolume.Value

    in the routine
    Private Sub slVolume_Change()
    with the msg run-time error '445' Object doesn't support action

    Min was originally set to -20
    Max was originally set to 0
    Value as originally set to -10

  9. #9
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    3,320

    Re: Volume Control

    Quote Originally Posted by AccessShell View Post
    I reviewed IBasicAudio.Volume and the program crashes on the statement
    Code:
     iAudio.Volume = Me.slVolume.Value

    in the routine
    Private Sub slVolume_Change()
    with the msg run-time error '445' Object doesn't support action

    Min was originally set to -20
    Max was originally set to 0
    Value as originally set to -10
    From MSDB article on IBasicAudio.Volume:

    "Returns a value from 10,000 (silence) to 0 (full volume). Each unit corresponds to .01 decibels. Not all devices support 10,000 distinct volume levels."

    Another caveat is that not all media files have audio and so reading/setting IBasicAudio.Volume "crashes" with "Object doesn't support action" -- MS used here an exception to signal failure, nothing fatal is happening.

    I would personaly try to *read* IBasicAudio.Volume on loading the media file and if error found then disable the volume control at all -- nothing to set here, no audio in this AVI file.

    cheers,
    </wqw>

  10. #10

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Volume Control

    I know the file I am playing has volume. I can adjust the volume with the vol control on the notification area of the taskbar.

    I'll try the read.

  11. #11

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Volume Control

    I now know why that most of the volume control software suggested, The ones that change the system volume, do not display the volume percentage. The volume number on the system volume, does not match the number returned from the routines. Only when the system volume is 100, or 0, do the numbers match. The difference is not the same for each system value.

    There, I only putting an up and down arrow on my form to control the volume. Each click will only adjust the value by 1.

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,867

    Re: Volume Control

    Open the system's Volume Mixer with your program running. That might help explain what you are seeing.

    But you wouldn't normally fiddle with either the output device ("Speaker" in most cases) level or even the process audio level in an application. Those are user settings.

    For an audio player based in DirectShow you would adjust IBasicAudio.Volume instead.

  13. #13

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Volume Control

    I tried using IBasicAudio.Volume. But,, it always gave an error msg. See post #8 in this thread.

  14. #14
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    3,320

    Re: Volume Control

    Quote Originally Posted by AccessShell View Post
    I tried using IBasicAudio.Volume. But,, it always gave an error msg. See post #8 in this thread.
    Try setting IBasicAudio.Volume to -100

    Try reading IBasicAudio.Volume, what's the value it returns?

    cheers,
    </wqw>

  15. #15

    Thread Starter
    Hyperactive Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    464

    Re: Volume Control

    Somewhere on this forum I got a zip file DirectShow Music.zip. I don't know if someone in this thread gave me a link to it, or if I searched for sound. Anyway, I thank the person who gave me the link. If you are on this thread, sorry, I couldn't find your reference.

    So, the reason why I kept crashing - , is because I did not have this line of code
    Code:
            Set IBasicAudio = FilgraphManager
    Everything works just fine now. It works how I would want it to work.

    Thanks to all.

  16. #16
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    3,320

    Re: [RESOLVED] Volume Control

    In this case the error message in #8 makes no sense -- it would have been "Object variable or With block variable not set" on IBasicAudio being Nothing.

    cheers,
    </wqw>

  17. #17
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,867

    Re: [RESOLVED] Volume Control

    My post got removed because I am at my attachments limit here.

    I was also suspicious of the solution above, and can only assume there was something else going on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width