Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Playing sounds in VB.NET

VB.NET form

  • Please log in to reply
20 replies to this topic

#13 Jarryd

Jarryd

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 63 posts
  • Location:Australia
  • Programming Language:C, Java, C++, C#

Posted 17 September 2010 - 08:02 PM

Great tutorial man :D
  • 0

#14 dwizzy

dwizzy

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 29 July 2011 - 07:41 AM

Hi I am new to VB and I was looking at this to play mutiple sound but for some reason this it never worked. What I am doing wrong here..



Public Class Form1
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Dim musicAlias As String
Dim musicPath As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
musicAlias = "myAudio"
musicPath = IO.Path.GetDirectoryName(Application.ExecutablePath) & "\sounds\super mario bros remix dj alexander.wav"
mciSendString("Open " & Chr(34) & musicPath & Chr(34) & " alias " & musicAlias, CStr(0), 0, 0)
mciSendString("Play " & musicAlias, CStr(0), 0, 0)
End Sub
End Class
  • 0

#15 elricworld

elricworld

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 13 September 2011 - 09:32 AM

Hi!
Your thread was very helpful!

I am able to play multiple sound at once,
but I wonder how to make a max/min volume to control the volume while playing the sound ?
can anyone help me ?

Thanks!
  • 0

#16 Tyrranus

Tyrranus

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 04 November 2011 - 10:16 PM

Is there an ability to loop music files this way?
sorry I am a total noob at coding and this was a huge help since all I wanted was to play background music and the occasional sound effect. Definite + rep, you saved me from killin someone for sure!!

edit:
and while Im pulling off my little thread necro here, Is it possible to use this to play a small 'playlist' of music? from the look of it I think I can sorta see how you could, but again I suck at this still

Edited by Tyrranus, 04 November 2011 - 10:52 PM.

  • 0

#17 Tyrranus

Tyrranus

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 06 November 2011 - 04:05 PM

noone?
  • 0

#18 Tyrranus

Tyrranus

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 10 November 2011 - 09:10 PM

:confused::crying:
  • 0

#19 AntoineDionne

AntoineDionne

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 30 November 2012 - 04:34 PM

Hello!

Thank you for the code that's working number 1!

2 question tho :)!

I've search arround the internet to find a way to put a button Volume + and Volume -, is there any command line that you know that can do this?

And is there a way to loop the music once it's done?

Thanks for any help!
  • 0

#20 NelsonWong

NelsonWong

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 15 January 2013 - 06:51 AM

Hi for this code here. i got a question. If i would to copy my program code and use it into another computer, it will not work right?? compare to the 1st one

Dim musicAlias As String = "myAudio"

Dim musicPath As String = "C:\Users\Public\Music\Sample Music\Symphony_No_3.wma"

this is the 1st one!




My.Computer.Audio.Play(musicPath, AudioPlayMode.BackgroundLoop)

My.Computer.Audio.Play(musicPath, AudioPlayMode.WaitToComplete)
  • 0

#21 Drakhtul

Drakhtul

    CC Lurker

  • New Member
  • Pip
  • 5 posts
  • Programming Language:(Visual) Basic
  • Learning:(Visual) Basic

Posted 10 February 2013 - 12:31 PM

nice, thanks :)


  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download