Skip to Main Content
Programming WPF, 2nd Edition
book

Programming WPF, 2nd Edition

by Chris Sells, Ian Griffiths
August 2007
Intermediate to advanced content levelIntermediate to advanced
864 pages
25h 52m
English
O'Reilly Media, Inc.
Content preview from Programming WPF, 2nd Edition

Audio and Video

WPF can incorporate video and audio into a user interface. The relationship between video and animation goes deeper than the superficial fact that they are both ways of showing moving images. The timeline and clock mechanisms you use in animation you can also use to control video and audio playback.

The fact that video or audio can connect with the animation timing system is useful if you want to synchronize animation with media. For example, suppose you wanted to present a recording in an application with a series of clickable bookmarks to jump directly to key points in the recording. You might want to arrange for these bookmarks to change appearance as the playback reaches the relevant point, allowing the user to see at a glance where the playback has reached. One way to do this is to create a timeline that changes each bookmark item at the appropriate time. By connecting this timeline with the media playback, you could guarantee that the visual changes to the bookmarks were always properly synchronized with the video or audio playback.

It's not always necessary to synchronize media and animations. WPF also lets you play media in a simpler "independent" mode. We'll look at this simple usage before seeing how to synchronize playback with animations.

Simple Media Playback

The easiest way to play video or audio media in WPF is to use the MediaElement, pointing its Source property at the media file you wish to play. Example 16-38 shows a MediaElement that will play one ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming C#, 4th Edition

Programming C#, 4th Edition

Jesse Liberty
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9780596510374Supplemental ContentErrata Page