Create a video player in Silverlight 2 – Part 2
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
13 comments so far
Leave a reply





You should add a screen shot at the end to show what you’ve created.
Great catch! Thanks for the suggestion.
Thank you for the great work. Much appreciated!
..Ben
[...] Create a Video Player in Silverlight 2 – Part 2 (Corey Schuman) [...]
When can we expect the “Buffering” and “progress” support that you promised?
The buffering progress post is almost finished. It will be available later tonight.
[...] Create a video player in Silverlight 2 – Part 2 [...]
really nice tutorial easy and funny to make:)
really nice tutorial
easy and funny to make:)
thanks
Thanks for the tutorial, i hope part 3 is coming soon.
it seems the mousedown event and mouseUp event of the scrubberSlider is not firing please resolve it.
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
[...] Links Source (11Mb because of the WMV) Part 2 of how to Create a video player in Silverlight 2 [...]