In part 1 we covered setting up a very basic video player. In part 2 we will add
- Scrubbing the video
- wiring up volume,
- and muting.
In future versions I will show how to display a buffer message, skin the controls, and how to work with media that’s not embedded in the xap.
- Scrubbing
- Add a MouseLeftButtonDown and MouseLeftButtonUp events for the slider in the constructor.

- Add a property to lock the scrubber while the mouse button is down.

- In the MouseLeftButtonDown event, set the scrubber lock to true.

- In the MouseLeftButtonUp event, release the lock on the scrubber and update the position of the video.

- Finally in the Tick event of the timer, prevent updating the position of the slider while the scrubber is locked.

- Add a MouseLeftButtonDown and MouseLeftButtonUp events for the slider in the constructor.
- Volume
- XAML. It important to set the Min to 0 and the Max to 1. The MediaElements volume ranges from 0 to 1.

- Register the ValueChanged event in the constructor for the slider.

- Set the video’s volume to the value in the ValueChanged event.

- Set the initial position of the slider to the video’s volume. You can either do this in the CurrentStateChanged event or the MediaOpened event of the MediaElement.

- XAML. It important to set the Min to 0 and the Max to 1. The MediaElements volume ranges from 0 to 1.
- Mute button
- Resulting player

Files:
Instead of the whole project (because the video is embedded in the project), here are the two important pieces of this project
UPDATE
If you are having problems with the Slider not recoginzing MouseLeftButtonUp or MouseLeftButtonDown events, check out the VideoSlider








April 15th, 2008 at 4:29 pm
You should add a screen shot at the end to show what you’ve created.
April 15th, 2008 at 5:06 pm
Great catch! Thanks for the suggestion.
April 16th, 2008 at 2:08 am
Thank you for the great work. Much appreciated!
..Ben
April 20th, 2008 at 1:17 am
[...] Create a Video Player in Silverlight 2 - Part 2 (Corey Schuman) [...]
April 21st, 2008 at 7:10 am
When can we expect the “Buffering” and “progress” support that you promised?
April 21st, 2008 at 12:03 pm
The buffering progress post is almost finished. It will be available later tonight.
April 21st, 2008 at 7:37 pm
[...] Create a video player in Silverlight 2 - Part 2 [...]
April 23rd, 2008 at 9:14 am
really nice tutorial easy and funny to make:)
April 23rd, 2008 at 9:15 am
really nice tutorial
easy and funny to make:)
thanks
June 30th, 2008 at 12:16 pm
Thanks for the tutorial, i hope part 3 is coming soon.
July 1st, 2008 at 1:25 pm
it seems the mousedown event and mouseUp event of the scrubberSlider is not firing please resolve it.
August 20th, 2008 at 4:14 am
Slider MouseLeftButtonDown/Up events bubbling no longer available in Beta 2, so you need to inherit Slider control and write your custom events
go here for more information
September 9th, 2008 at 3:08 pm
[...] Links Source (11Mb because of the WMV) Part 2 of how to Create a video player in Silverlight 2 [...]
October 21st, 2008 at 8:30 am
Thanks you very much!
Your work helped me a lot thanks.
October 24th, 2008 at 4:41 am
Hi, nice article! Could you post the buffering-code as promised? Or have you filed it under a different article?
March 3rd, 2009 at 11:34 am
In Part 2 the links for XMAL and C# goes to your web site and I can’t find the files.
March 5th, 2009 at 10:07 am
Hello Corey,Thanks for the email reply. This seems like a really nice project. I think I got everything for Part 2 added correctly but I have a few problems.1. I don’t have Bear.wmv so I substutited another .wmv. But nothing plays when I click the play button. Maybe my .wmv is incompatable but it works outside of this project.2. When it opens it starts with Pause instead of Play in the button. Easy enought to change.3. 00.00 is not in front of Volume. Maybe it needs to start to get that?4 Mute/Unmute is empty when it opens. It works when clicking. That seems to be ok.5. Biggest problem. Nothing plays. I just get a black screen.Thanks, Jim
March 22nd, 2009 at 11:15 am
Hi Corey,
I am having the same problem as Jim above. I’d really appreciate your help in getting the files.
BTW, are you in Vancouver BC? So am I.
laters
Helen
April 27th, 2009 at 7:35 am
Hi!
If You’re encountering problems with firing slider’s mouse button events, You can try progressbar. Events work fine, all you need to add is mouse move event, and then calculate new position for video and new value for progressbar.
May 4th, 2009 at 9:25 pm
nice, tutorial…
June 23rd, 2009 at 12:18 pm
I keep hearing about this stuff. Really interesting. I have looked online and found some other blogs that offer some information, but not as much as on this site. Your blog is definitely going in my subscription program!