Results 1 to 3 of 3

Thread: [02/03] Music When Form Loads

  1. #1

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Question [02/03] Music When Form Loads

    here is what i mean, When my app opens how do i have it play music without opeing a media player i just want my app to play a simple noise when it starts, is there a way you can do this?

    Im using VB.net 2003

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,467

    Re: [02/03] Music When Form Loads

    If you're talking about a WAV sound then you would use the PlaySound API. If you want MIDI or something else then it's more complex. Follow the Mentalis link in my signature. They have a simple class for WAV files and a more complex class for other sound formats. You can use their class as is or you can take look at their source and use just what you need in your own code. Fortunately sound support is better in 2005.

  3. #3
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,817

    Re: [02/03] Music When Form Loads

    Quote Originally Posted by FireKnox101
    here is what i mean, When my app opens how do i have it play music without opeing a media player i just want my app to play a simple noise when it starts, is there a way you can do this?

    Im using VB.net 2003
    Hi,

    This is how I'm playing music without using Media Player.

    VB Code:
    1. Const SND_ASYNC As Integer = &H1
    2.     Const SND_FILENAME As Integer = &H20000
    3.     Const SND_NODEFAULT As Integer = &H2
    4.     Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal        lpszName As String, ByVal hModule As Integer, ByVal dwFlags As Integer)
    5. As Integer
    6.  
    7. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    8.         PlaySound(Where your wav file is on the harddisk and is Name, 0, SND_NODEFAULT Or SND_ASYNC Or SND_FILENAME)
    9.     End Sub

    Try it,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

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