O'Reilly logo

Pro Silverlight 5 in VB by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The MediaElement

In Silverlight, all the audio and video functionality is built into a single class: MediaElement.

Like all elements, a media element is placed directly in your user interface. If you're using the MediaElement to play audio, this fact isn't important, because the MediaElement remains invisible. If you're using the MediaElement for video, you place it where the video window should appear.

A simple MediaElement tag is all you need to play a sound. For example, add this markup to your user interface:

<MediaElement Source="test.mp3"></MediaElement>

Now, once the page is loaded, it will download the test.mp3 file and begin playing it automatically.

Of course, for this to work, your Silverlight application needs to be able to find ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required