WPF MediaElement for Media Player

This article is written by Pon Saravanan  on 09-Sep-09 Last modified on :04-Jan-10

Subscribe to my RSS Feed!

Media Player using WPF MediaElement

Initially I started the Car PC project with WinForms Project. But after some time once the functionalities are almost frozen,I realized WPF will be a good replacement for this. since i can style this with various effects easily. I am now working on WPF based player mediaelement that can take the Songs Play List from my own Microsoft Access based Play List Library and play using MediaElement.

Media Player for WPF audio player

Play: To play the selected song.If it is already playing pause it,
Pause : To pause the selected song.If it is already paused then resume from the current location,
Stop: To stop the currently playing song,
Previous Song : Stop the current song and Play the previous song
Next Song,: Stop the current song and go to next song
Fast Forward: Fast Forward the current song by setting the current play location for fast forward wpf mediaelement
Rewind:Rewind the current song by setting the current play location

MediaElement to play songs

As the player mediaelement is somehow equivalent to the Windows Media Player Control in WinForms. Still it has few changes on how to utilize it. For understanding Purpose we name this control as CarMediaPlayer

For specifiying a media file to this control we need to use .Source like following

CarMediaPlayer.Source = new Uri(FilePath);

For palying the file  we need to use .Play like following. But please ensure the Source is already set as we discussed in the earlier point
CarMediaPlayer.mediaPlayerMain.Play()

As while playing we may need to pause the song. To pause we need to call the function Pause(). But actually can be switched with the same button usinga boolean.While clicking the value has to be switched to false from true or true from false. Then based on the value we can Play or Pause the Player.
CarMediaPlayer.mediaPlayerMain. Pause()

In the same way we can stop the playing song also Use the function Stop() .
CarMediaPlayer.mediaPlayerMain. Stop ()

There are few more useful properties can be used to enhance the user experience
CarMediaPlayer.Volume
CarMediaPlayer.Position










GUEST
11/26/2009 3:02:27 AM


Comments
   
Captcha Image
For you specially:  
Captcha Text Enter the text in the image.(Not Case sensitive)