Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using following code

Const DATA_FILE_EXTENSION As String = ".mp3"
        Dim dlgFileDialog As New OpenFileDialog
        With dlgFileDialog
            .Filter = DATA_FILE_EXTENSION & _
            " files (*" & DATA_FILE_EXTENSION & "|*" & DATA_FILE_EXTENSION
            .FilterIndex = 1
            .RestoreDirectory = True
            If .ShowDialog() = DialogResult.OK Then
                'Play the sound file
                Me.AxWindowsMediaPlayer1.URL = dlgFileDialog.FileName
            End If
        End With
Posted
Updated 22-Feb-11 15:51pm
v2
Comments
Eydaqmee 15-Apr-11 3:49am    
I also use this code to play music but it still have error.
this the error " AxWindowsMediaPlayer1' is not a member of 'MFTRead.Form1'".
How to solve this error..
i really need your help..

This code doesn't do anything other than tell Media Player which file to play. Your code can't do anything to clean up the sound. If you open the file directly in Media Player yourself (not through your code) it'll do the exact same thing. The problem seems to be with the file you're playing or with the codec you have installed for the .MP3 format.
 
Share this answer
 
Comments
somil030 22-Feb-11 22:58pm    
its taking mp3 file,than what can i do now??because my all mp3 file and player does not play properly now...
Dave Kreskowiak 22-Feb-11 23:10pm    
I already told you what the problem is. You've got a screwed up codec and you'll have to replace it with something. Google for "Media Player MP3 codec" and you'll find something.
somil030 23-Feb-11 0:14am    
i successfully install k-lite codec,now what can i do?change file format in code?
standard audio files do play, but a certain MP3, AVI or WMV file does not produce audio, the first thing to try is to install missing codecs as Dave said.

You can try and find out which codec is required and then find and install that code and try it.

Hope this will help you.
 
Share this answer
 
Comments
somil030 22-Feb-11 23:38pm    
what can i change in my code?and what can do for replace my codec???
Nithin Sundar 22-Feb-11 23:49pm    
As far as I know, there are many codec packs on the net. I use K-lite which seems reasonable. You can check it out.
somil030 23-Feb-11 0:01am    
i successfully install k-lite codec,now what can i do?change file format in code?
Dave Kreskowiak 23-Feb-11 7:53am    
Come on. You can't change the file format in your code. Forget your code for now. If you can't play an MP3 in the normal Media Player, you're code can't do anything about it. Just try playing an MP3 normally in Media Player. Why is this so hard to figure out??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900