Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to play a wav file

floozyfloozy Posts: 38Member
Hi there,

I couldnt find anything about playing wav files, does anyone know what I can use? Namespace, class etc.

thanks
carsten

Comments

  • mumpizmumpiz Posts: 75Member
    : Hi there,
    :
    : I couldnt find anything about playing wav files, does anyone know what I can use? Namespace, class etc.
    :
    : thanks
    : carsten
    :

    I almost have same problem, I found samples of playing wav files but these are all playing files the user chooses from OpenFileDlg.

    Its not even a lot of code. If file cant be found a default sound is played.

    insert this:

    [DllImport("winmm.dll")]

    public static extern long PlaySound(String lpszFileName, long hModule, long dwFlags);

    //then call methode

    PlaySound("mySound.wav", 0,0);

    Works well but doesnt play my sound!! Plays default instead

    Can anyone tell me how to get to the wav file that I included in project as a built in ressource in seperate folder????


  • heiko.boettgerheiko.boettger Posts: 2Member
    : Hi there,
    :
    : I couldnt find anything about playing wav files, does anyone know what I can use? Namespace, class etc.
    :
    : thanks
    : carsten
    :

    Hi,

    you could also use the mediaplayer-control or directx9 managed.
  • floozyfloozy Posts: 38Member
    : Hi,
    :
    : you could also use the mediaplayer-control or directx9 managed.
    :
    Thanks for Your reply, could You be a bit more specific about how I include that, namespace etc. As Im still an apprentice with just about 16 months of training Im not too familiar with managed code.

    I tried whatever Mumpiz wrote, and it doesnt play sound I like to play. Only windows default failure wav.

    ta

    cya
  • heiko.boettgerheiko.boettger Posts: 2Member
    [b][red]This message was edited by heiko.boettger at 2004-1-13 8:41:37[/red][/b][hr]
    : : Hi,
    : :
    : : you could also use the mediaplayer-control or directx9 managed.
    : :
    : Thanks for Your reply, could You be a bit more specific about how I include that, namespace etc. As Im still an apprentice with just about 16 months of training Im not too familiar with managed code.
    :
    : I tried whatever Mumpiz wrote, and it doesnt play sound I like to play. Only windows default failure wav.
    :
    : ta
    :
    : cya
    :

    You could add the mediaplayer to your toolbar by using the "Customize Toolbox" command which can be found in the "Tools" menu. Select the windows media control and add it. The mediaplayer-control is now available in your toolbar and can be used like the other control.

    In order to play a mediafile you could the following code:

    axMediaPlayer1.URL="music.mp3";
    axMediaPlayer1.controls.play(); //if autoplay=false (property)

    More information can be found at:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay/mmp_sdk/playercontrolguide.asp





Sign In or Register to comment.