C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Mp3 Player in WPF using DirectX Dll's


Posted Date:     Total Responses: 0    Posted By: Hefin Dsouza   Member Level: Diamond   Points/Cash: 10   


Simple MP3 Player


Introduction : This is a simple Music Player that can play single Mp3 Songs at a time. It is a very basic player with Fast Forward, Rewind , Stop and Play Functions. The Player also displays Mp3 Information like Total Duration of the Song , Remaining Time , Elapsed Time and Status.


Technical Information : The Project makes use of a number of External Dll's for functionality.


1)Microsoft.DirectX.AudioVideoPlayback.dll

 2)Microsoft.DirectX.Direct3D.dll


3)Microsoft.DirectX.DirectPlay.dll

4)Microsoft.DirectX.DirectSound.dll


5)Microsoft.DirectX.dll


Understanding The Code : Below I have demonstrated some steps that will allow you to build your own MP3 Player in .Net.

(Please Note The Below Code is In Visual Basic. Net)


Initial Steps :

1)You need to Add Reference to The Above Mentioned Dll's (You will find it in the Attachment)
2)Import the following Namespaces

Imports Microsoft.DirectX

Imports Microsoft.DirectX.AudioVideoPlayback

Imports Microsoft.DirectX.Direct3D

Imports Microsoft.DirectX.DirectPlay

Imports Microsoft.DirectX.DirectSound


3)Create an Object of Audio Class

Dim song As Audio




4)To Load the Mp3 In the Audio object and to Play


Private Sub playBtn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles playBtn.Click


openfile.Filter = "Audio Files(*.wav,*.mp3,*.cda)|*.wav;*.mp3;*.cda"


If openfile.ShowDialog() = Forms.DialogResult.OK Then


TextBox1.Text = openfile.FileName

song = New Audio(TextBox1.Text)


songTrack.Maximum = song.Duration

song.Play()
tm.Interval = 60


tm.Start()


StLabel.Content = "Status : Playing"
End If
End Sub





5)To Stop a Playing Song

Private Sub stopBtn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles stopBtn.Click


Try


song.Stop()


Catch ex As Exception



End Try


End Sub






6) For Fast Forward and Rewind


Private Sub forwBtn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles forwBtn.Click


Try
song.CurrentPosition += 2


Catch ex As Exception


Try

song.CurrentPosition = song.Duration

Catch ex1 As Exception


End Try


End Try



End Sub



'For Rewind


Private Sub rewindBtn_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles rewindBtn.Click


Try


song.CurrentPosition -= 2


Catch ex As Exception


Try

song.CurrentPosition = 0


Catch ex1 As Exception


End Try


End Try


End Sub





These were some of the Important code's to create your own MP3 Player.
I have Attached the working Copy of the Whole Project along with the source code.
Important Note : To Run the Sample You need to Have
a) Visual Studio 2008 Service Pack 1
b) .Net Framework 3.5 + Service Pack 1
c) DirectX Compatible Sound Card
d) Speakers
e) Few Mp3 Songs to Test

Future Upgrades : I had stopped developing this Application Further because i did not have enough time.
I would love It if DotNetSpider Members Add More Features to it and Upload the same over here.
Some Features I have Planed of are
1) Adding Visualization's
2) Play List Support
3) Adding Video Support
And Many More.....

For Any Assistance Please Feel Free to Contact Me


Regards Hefin Dsouza
[Editor DotNetSpider]



Attachments




ScreenShot1
  • Dll's Required To Run The Applications (441-15727-Dll To Use.rar)
  • Full Source Code (441-15728-MusicTimeDemo.rar)

  • Project Feedbacks

    Author: Prateek TripathiMember Level: BronzeRevenue Score: 1 out of 5
    hey dude

    could you please help me in choosing a project in visual basic?


    Post Feedback
    You must Sign In to post a feedback.
    Next Project: A Complete Employee Details From A table Display’s on a UI(Front end Database is Dataset):
    Previous Project: Simple Logon Screen Changer Using WPF and VB.Net

    Return to Project Index

    Post New Project


    Related Projects



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use