10 Replies - 55775 Views - Last Post: 26 March 2013 - 09:12 AM Rate Topic: -----

#1 chandumy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-June 08

how to play mp3 in vb.net

Post icon  Posted 17 July 2008 - 10:19 PM

Hai


this is chandrashekar i am working on a project in that project to create impression to othersI want to play a background music so please help me....
Is This A Good Question/Topic? 0
  • +

Replies To: how to play mp3 in vb.net

#2 Damage  Icon User is offline

  • Lord of Schwing
  • member icon

Reputation: 57
  • View blog
  • Posts: 1,243
  • Joined: 05-June 08

Re: how to play mp3 in vb.net

Posted 17 July 2008 - 10:31 PM

well i'm not too sure on how to run mp3's directly from vb but if you use something like

Process.Start("winamp.exe", "c:\MP3Name.mp3")



you can open the program needed to play mp3's. I know you can use

My.Computer.Audio.Play("c:\WAVName.wav")



but as far as i know it only works for .wav files. So maybe you could try convert your mp3 to wav and play it like that.
Was This Post Helpful? 0
  • +
  • -

#3 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: how to play mp3 in vb.net

Posted 17 July 2008 - 11:04 PM

Google Me
Was This Post Helpful? 0
  • +
  • -

#4 Damage  Icon User is offline

  • Lord of Schwing
  • member icon

Reputation: 57
  • View blog
  • Posts: 1,243
  • Joined: 05-June 08

Re: how to play mp3 in vb.net

Posted 17 July 2008 - 11:18 PM

Quote

There's various ways to do it. For basic playback functionality, with Managed DirectX you can do something like... (source)

AudioVideoPlayback.Audio mp3 = new AudioVideoPlayback.Audio(mySong.mp3);
mp3.Play();

There's a good chance you have the MDX dll installed already, look in windows\assembly if you find Microsoft.DirectX.AudioVideoPlayback there.. Just reference it from your project if you have it. If not then you might try the august DirectX update:

http://www.microsoft...;DisplayLang=en

You may need to distribute what MDX dll's your app needs with it or the user will need to install the above as well.

There's also the latest October update but it says something about beta and for VS2005 Beta 2, so it may not work.

If you need something advanced later http://sourceforge.n.../directshownet/ may be of help but not as simple.


Other options may be embedding Media Player control, using pinvoke or getting a library.


well now i know. :)

This post has been edited by Damage: 17 July 2008 - 11:21 PM

Was This Post Helpful? 0
  • +
  • -

#5 ─ndrew  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 312
  • Joined: 21-April 08

Re: how to play mp3 in vb.net

Posted 17 July 2008 - 11:48 PM

Well if your Australian last year in the PC mag PCUser there was a tutorial how to do this with all formats. Ill rewrite the tutorial for you because I cant find a link on the internet I hate going through my pc mags soo many of them!!

─ndrew
Was This Post Helpful? 0
  • +
  • -

#6 jagatworld  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 11-May 08

Re: how to play mp3 in vb.net

Posted 18 July 2008 - 12:23 AM

Hi guys.....

Dont work on this tooooo much.......

There is already a wonderful Tutorial in this DIC on how to make an MP3 Player in VB.Net.

Just follow this link and you are there !

http://www.dreaminco...wtopic57357.htm

Enjoy........
:)
Was This Post Helpful? 0
  • +
  • -

#7 bagonks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 21-May 09

Re: how to play mp3 in vb.net

Posted 21 May 2009 - 02:03 AM

help me load playlist m3u using vb.net?

this code create using vb 6

Public Function LoadM3U(ByVal strFileName As String, ByRef strFilePaths() As String, ByRef strNames() As String) As Boolean

'Error handler
On Error GoTo ErrHap

'Declare variables
Dim lngFileNo As Long
Dim strTemp As String
Dim i As Long
Dim strLines() As String
Dim lngLines As Long
Dim strM3ULoc As String

'Check if file exists
If Dir(strFileName) <> "" Then

'Get M3U location
strM3ULoc = Left$(strFileName, InStrRev(strFileName, "\"))

'Get new file number
lngFileNo = FreeFile

'Open the file
Open strFileName For Input As lngFileNo

'Get the file
strTemp = Input(LOF(lngFileNo), #lngFileNo)

Close lngFileNo

'Split the file into it's lines
strLines = Split(strTemp, vbCrLf)

'Check that this file has enough lines
If UBound(strLines) > 2 Then

'Check that it's an M3U file
If strLines(0) = "#EXTM3U" Then

'Get number of lines
lngLines = UBound(strLines)

'Attention! If you have any errors over the next 2 lines then you need to make sure
'that you have declared the array variables without specifying their size,
'because here we're changing their sizes to match. - Thanks
ReDim strFilePaths(0 To (lngLines / 2)) As String
ReDim strNames(0 To (lngLines / 2)) As String

'Loop through each line
For i = 1 To lngLines

'Check what kind of data we've got
If Left$(strLines(i), 7) = "#EXTINF" Then

'File name & length (but we don't return that). Get file name
strNames((i - 1) / 2) = Right$(strLines(i), Len(strLines(i)) - InStr(1, strLines(i), ","))

Else
'File path. Verify the path
If Dir(strLines(i)) <> "" Then
'Pure path, including drive letter
strFilePaths((i / 2) - 1) = strLines(i)
ElseIf Dir(strM3ULoc & strLines(i)) <> "" Then
'Adding onto the M3U's path (most common)
strFilePaths((i / 2) - 1) = strM3ULoc & strLines(i)
ElseIf Dir(Left$(strM3ULoc, 3) & strLines(i)) <> "" Then
'Adding onto the M3U's drive only
strFilePaths((i / 2) - 1) = Left$(strM3ULoc, 3) & strLines(i)
Else
'Display error message
Call MsgBox("Cannot find file!" & vbCrLf & strLines(i), vbExclamation, "Error while loading a file!")
End If
End If

Next i

'Set return value to true
LoadM3U = True

End If

Else
'Return error
LoadM3U = False
End If

Else
'Return error
LoadM3U = False
End If

Exit Function
ErrHap:
'Check error
If Err.Number = 10 Then
'Display message and exit function
Call MsgBox("Cannot accept fixed length arrays!", vbExclamation, "Error - Function 'LoadM3U'")
Exit Function
End If

'Display error
Call MsgBox(Err.Description & " Number: " & Err.Number, vbExclamation)

'Set return value
LoadM3U = False

End Function

please top code convert to vb.net
please
please
Was This Post Helpful? 0
  • +
  • -

#8 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: how to play mp3 in vb.net

Posted 21 May 2009 - 03:11 AM

@bagonks,

It is best to start a new thread then continue on from one that is about 1 year old. Make a new one and describe the problems which have occured. Thanks.
Was This Post Helpful? 0
  • +
  • -

#9 MadsHaupt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-March 13

Re: how to play mp3 in vb.net

Posted 26 March 2013 - 08:18 AM

View Postfirebolt, on 21 May 2009 - 03:11 AM, said:

@bagonks,

It is best to start a new thread then continue on from one that is about 1 year old. Make a new one and describe the problems which have occured. Thanks.


Simply enter PROJECT -> Add Reference... and clicking on COM, and then you vŠlje Windows Media Player number 2 (file path C: \ Windows \ System32 \ msdxm.tlb).

Once you have done this, you should write
Dim a As New MediaPlayer.MediaPlayer
a.FileName = FileName
a.PlayCount = PlayCount
a.ShowDialog(MediaPlayer.MPShowDialogConstants.mpShowDialogContextMenu)


a.Play()
a.Stop()
a.Pause()

Was This Post Helpful? 0
  • +
  • -

#10 MadsHaupt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-March 13

Re: how to play mp3 in vb.net

Posted 26 March 2013 - 08:54 AM

View PostMadsHaupt, on 26 March 2013 - 08:18 AM, said:

View Postfirebolt, on 21 May 2009 - 03:11 AM, said:

@bagonks,

It is best to start a new thread then continue on from one that is about 1 year old. Make a new one and describe the problems which have occured. Thanks.


Simply enter PROJECT -> Add Reference... and clicking on COM, and then you vŠlje Windows Media Player number 2 (file path C: \ Windows \ System32 \ msdxm.tlb).

Once you have done this, you should write
Dim a As New MediaPlayer.MediaPlayer
a.FileName = FileName
a.PlayCount = PlayCount
a.ShowDialog(MediaPlayer.MPShowDialogConstants.mpShowDialogContextMenu)


a.Play()
a.Stop()
a.Pause()


http://www.youtube.c...h?v=oBEWLwk_bw0
Was This Post Helpful? 0
  • +
  • -

#11 IronRazer  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 368
  • View blog
  • Posts: 1,076
  • Joined: 01-February 13

Re: how to play mp3 in vb.net

Posted 26 March 2013 - 09:12 AM

View PostMadsHaupt, on 26 March 2013 - 10:54 AM, said:

View PostMadsHaupt, on 26 March 2013 - 08:18 AM, said:

View Postfirebolt, on 21 May 2009 - 03:11 AM, said:

@bagonks,

It is best to start a new thread then continue on from one that is about 1 year old. Make a new one and describe the problems which have occured. Thanks.


Simply enter PROJECT -> Add Reference... and clicking on COM, and then you vŠlje Windows Media Player number 2 (file path C: \ Windows \ System32 \ msdxm.tlb).

Once you have done this, you should write
Dim a As New MediaPlayer.MediaPlayer
a.FileName = FileName
a.PlayCount = PlayCount
a.ShowDialog(MediaPlayer.MPShowDialogConstants.mpShowDialogContextMenu)


a.Play()
a.Stop()
a.Pause()


http://www.youtube.c...h?v=oBEWLwk_bw0

You do realize this topic is about 4 or 5 years old. :unsure:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1