Results 1 to 6 of 6

Thread: Simple Wav File Playing

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    7

    Question

    Just a quick question, how can I play a wave file in a visual basxic program without needing a command button. Say i wanted to play a wave file on a Got_Focus() event, how could I go about doing so?

  2. #2
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266

    Smile

    playing wave files' E Z.
    if you're not using Windows 2000, do this:
    (Multimedia Control ain't work'n with 2000)

    steps:

    right-click toolbox.
    select Microsoft MultiMedia Control 6.0
    (or 5.0, if you have VB 5.0)
    click OK.


    here's de code:
    (inside your module that contains the object that is
    going to receive focus)


    Option Explicit

    Private Sub WhatEver_GotFocus()
    MMControl1.DeviceType = "WaveAudio"
    MMControl1.FileName = "C:\WINNT\MEDIA\TADA.wav"
    MMControl1.Command = "open"
    MMControl1.Command = "play"
    End Sub


    There is an alternative. You can use
    the Windows Media Player ActiveX control, or you can write
    lots of assembly code inside C++ to make your own ActiveX
    control that plays media files.



    [Edited by jovton on 11-20-2000 at 03:48 AM]

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    7

    Talking :p Thanx alot.

    Thanks man, that helped out alot..

  4. #4
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266

    Cool

    hey, Divide_0verride!

    saw my signature? i love to help out newbies! and, i am
    a newbie myself. but i do have some experience in vb and
    c++, and yes, even vc++ programming. some pascal and
    delhpi too! man, i'd love to learn some assembly language!

    anyway, it was nice help'n ya.
    jovton

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I don't think you actually need a control to play wav files, you can use the PlaySound API.

    In a module:

    Code:
    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" ( _
        ByVal lpszName As String, _
        ByVal hModule As Long, _
        ByVal dwFlags As Long _
    ) As Long
    In your code:

    Code:
    PlaySound "C:\WINNT\MEDIA\TADA.wav", 0, 0
    Harry.

    "From one thing, know ten thousand things."

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    7

    Thanks

    thanks alot both of you... it's been a great help.. my project is nearing it's completion date, and it is crunch time.. laters

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