API CD Player

My CD Player will play musical CDs. Some built-in commands are play, pause, stop, rewind, fast forward, previous track, next track, open, close, and exit. I also added a combo box for easier track selection and a volume control to adjust volume.

Screen-shot

Some API calls it uses are:


Declare Function mciGetErrorString Lib "winmm.dll" Alias _
   "mciGetErrorStringA" _
   (byval dwError as Long, byval lpstrBuffer as string, _
    byval uLength as Long) as Long
Declare Function mciSendString Lib "winmm.dll" Alias _
    "mciSendStringA" _
   (byval lpstrCommand as string, byval _
   lpstrReturnString as string, _
    byval uReturnLength as Long, byval hwndCallback as Long) _
    as Long
'
public hmem as Long
'
public Const SND_ASYNC = &H1
public Const SND_NODEFAULT = &H2
public Const SND_PURGE = &H40
public Const SND_FILENAME = &H20000
'
public Const MMSYSERR_NOERROR = 0
public Const MAXPNAMELEN = 32
public Const MIXER_LONG_NAME_CHARS = 64
public Const MIXER_SHORT_NAME_CHARS = 16
public Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
public Const MIXER_GETCONTROLDETAILSF_VALUE = &H0&
public Const MIXER_SETCONTROLDETAILSF_VALUE = &H0&
public Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&
public Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
public Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
public Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = _
               (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
public Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = _
               (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
public Const MIXERLINE_COMPONENTTYPE_SRC_LINE = _
               (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
public Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
public Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
public Const MIXERCONTROL_CONTROLTYPE_FADER = _
               (MIXERCONTROL_CT_CLASS_FADER Or _
               MIXERCONTROL_CT_UNITS_UNSIGNED)
'
public Const MIXERCONTROL_CONTROLTYPE_VOLUME = _
               (MIXERCONTROL_CONTROLTYPE_FADER + 1)
'
public Type MIXERCONTROLDETAILS
    cbStruct    as Long
    dwControlID as Long
    cChannels   as Long
    item        as Long
    cbDetails   as Long
    paDetails   as Long
End Type
'
public Type MIXERCONTROLDETAILS_UNSIGNED
    dwValue as Long
End Type
'
public Type MIXERCONTROL
'
public Type MIXERLINE
'
'Allocates the specified number of bytes from the heap.
'
Declare Function GlobalAlloc Lib "kernel32" (byval _
    wFlags as Long, _
    byval dwBytes as Long) as Long
'
'Locks a global memory object and returns a pointer to the
' first byte of the object's memory block.  The memory block
' associated with a locked object cannot be moved or discarded.
'
Declare Function GlobalLock Lib "kernel32" (byval _
    hmem as Long) as Long
'
'Frees the specified global memory object and invalidates
'its handle.
'
Declare Function GlobalFree Lib "kernel32" (byval hmem as Long) _
    as Long
'
Declare Sub CopyPtrFromStruct Lib "kernel32" Alias _
    "RtlMoveMemory" _
    (byval ptr as Long, struct as Any, byval cb as Long)
'
Declare Sub CopyStructFromPtr Lib "kernel32" Alias "RtlMoveMemory" _
    (struct as Any, byval ptr as Long, byval cb as Long)
'
'Opens a specified mixer device and ensures that the
'device will not be removed until the application
'closes the handle.
'
Declare Function mixerOpen Lib "winmm.dll" _
    (phmx as Long, byval uMxId as Long, byval dwCallback as Long, _
    byval dwInstance as Long, byval fdwOpen as Long) as Long
'
'Sets properties of a single control associated with an
'audio line.
'
Declare Function mixerSetControlDetails Lib "winmm.dll" _
    (byval hmxobj as Long, pmxcd as MIXERCONTROLDETAILS, _
    byval fdwDetails as Long) as Long
'
'Retrieves information about a specific line of a mixer device.
'
Declare Function mixerGetLineInfo Lib "winmm.dll" _
    Alias "mixerGetLineInfoA" (byval hmxobj as Long, _
    pmxl as MIXERLINE, byval fdwInfo as Long) as Long
'
'Retrieves one or more controls associated with an audio line.
'
Declare Function mixerGetLineControls Lib "winmm.dll" _
    Alias "mixerGetLineControlsA" (byval hmxobj as Long, _
    pmxlc as MIXERLINECONTROLS, byval fdwControls as Long) _
    as Long
'
public Function fGetVolumeControl(byval hmixer as Long, _
        byval componentType as Long, byval ctrlType _
        as Long, _
        byref mxc as MIXERCONTROL) as Boolean
'

Download zipped project files (30k)


Comments

  • Hello

    Posted by mourya09 on 05/16/2006 12:27am

    Your pgm is very nice

    Reply
  • How to select which CDROM

    Posted by Legacy on 01/22/2004 12:00am

    Originally posted by: robbage

    So how do you select which CDOM drive to control? This program defaults to the wrong drive.

    Reply
  • how to record

    Posted by Legacy on 01/07/2004 12:00am

    Originally posted by: Gultekin

    Hi,
    
    

    I want to ask how that you can record a sound in visual basic?

    For example: you make a piano with buttons. Each button makes a sound if you click on it.
    My problem is how you can save this sound in a database,
    and then play it again. You can really help me if you can send me some ideas.
    I'm really stuck here.

    Kind regards,

    Reply
  • Volume Control?

    Posted by Legacy on 12/05/2003 12:00am

    Originally posted by: B1GR3D

    Hey ive been searching for a way to change the volume for like 3 months now lol and previously found out im going to need this API to do it.

    I was wondering if you had the time could you send me the API for just changing the volume or make an example program itd be greatly appreciated and an example program might be a gd idea for others like me to also learn how to use it :)

    Reply
  • http://www.codeguru.com/vb/articles/2165.shtml

    Posted by Legacy on 09/02/2003 12:00am

    Originally posted by: Loc Huynh Gia

    I need the code very much but I can't download it from the given page

    Reply
  • please

    Posted by Legacy on 08/18/2003 12:00am

    Originally posted by: nimbargi

    please send greate cd player source code for final year project.

    Reply
  • Well That Is Amazing

    Posted by Legacy on 07/18/2003 12:00am

    Originally posted by: ZISHAN

    Amazing amazing & amazing......
    

    Reply
  • you can download as bellow

    Posted by Legacy on 06/21/2003 12:00am

    Originally posted by: sanggy shin

    http://www.codeguru.com/vb/articles/2165_Cd_Player.zip

    Reply
  • I want to write data to CD Writer using vc++

    Posted by Legacy on 05/07/2003 12:00am

    Originally posted by: Manoj

    I have a VC++ program which contains a file.I want to write that file to my CD Writer(can be of any type).
    Pls help me if U can........

    Reply
  • requesting for file to download

    Posted by Legacy on 05/02/2003 12:00am

    Originally posted by: srikanth

    hi u r work seem's to be great ,but i have seen or made to ur project,so please mail to me to download as zip file
    
    my e-mailid is-srikanthmn_2003@yahoo.com
    thank u

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds