Inserting audio and video
In Blend for Visual Studio 2012, you can add media files to your project such as audio and video.
For instructions about how to add a media files to your project, see Insert an image file into the active document and Insert an audio or video file into the active document.
Audio
Blend supports audio file types such AIF, AIFC, AIFF, ASF, AU, MID, MIDI, MP2, MP3, MPA, MPE, RMI, SND, WAV, WMA, and WMD. These are all file formats that Windows Media Player 10 supports.
[!REMARQUE]
Microsoft Silverlight supports only the MP3 and WMA file types.
After you add an audio file to your project, you can add it to the artboard by double-clicking the audio file name in the Projects panel, or by setting the Source property of an existing MediaElement control to the name of the audio file.
[!REMARQUE]
You can't reverse an audio clip in Blend by reversing the storyboard that contains the audio timeline.
Video
Blend supports video file types such as ASF, AVI, DVR-MS, IFO, M1V, MPEG, MPG, VOB, WM, and WMV. These are all file formats that Windows Media Player 10 supports.
[!REMARQUE]
Silverlight supports only the WMV file type.
You will not be able to insert other video file types into a document, although you will be able to add them to your project by using a MediaElement control. You can add a MediaElement control from the Assets panel to your document and then modify its Source property to point to a media file type that Blend does not recognize to make sure that the video plays in your application at run time.
[!REMARQUE]
You can't reverse a video clip in Blend by reversing the storyboard that contains the video timeline.
[!REMARQUE]
To work with media in Blend, you must have Windows Media Player 10 installed on your computer. You can download Windows Media Player 10 from the Windows Media website.
Audio and video in WPF projects
After you insert an audio file or video clip into your document, you can control its playback using the media timeline that was created for it in the Objects and Timeline panel. You can do the following things with a media timeline:
Modify the properties of a media element selected in the Objects and Timeline panel. You can change properties such as volume, balance, and speed in the Media category of the Properties panel.
Manually move the timeline by selecting the Selection tool in the Tools panel, and then dragging the gray time bar. You can also right-click the shaded time bar to select the looping options.
For more information, see the topics listed in Set the loop duration.
Copy and paste the media element in the Objects and Timeline panel, and then move the various time bars to schedule the sound to occur at different times.
Configure a control such as a button to start and stop the media timeline.
For an example, see Control media using triggers in a timeline.
Change the media timeline in the code-behind file just as you would change an animation timeline. For information, see the Storyboards Overview topic on MSDN. The following code example is a very simple example in C# to show the minimal necessary lines of code to start a storyboard:
using System.Windows.Media; using System.Windows.Media.Animation; // In a method... Storyboard audioResourceWav; audioResourceWav = (Storyboard)this.Resources["AudioResource_wav"]; audioResourceWav.Begin(this);
Synchronizing media with other timelines
If a storyboard contains both media (video or audio) and animation timelines, the animation timelines might appear to begin before the media timeline if the media timeline is delayed because of loading time. You can use the XAML SlipBehavior attribute to start all the timelines at the same time.
For instructions about how to synchronize timelines, see Synchronize the starting times of animation and media timelines.
Audio and video in Silverlight projects
After you insert an audio file or video clip into your document, you can control its run-time behavior (such as playback, download progress, and buffering progress) using the properties and events of the Silverlight MediaElement object that was created for it in the Objects and Timeline panel.
For more information, see MediaElement States (Silverlight) on MSDN.
Alternatively, you can use Microsoft Expression Encoder to create a full-featured media player to display your media by using a Silverlight template.
For more information, see Customize an Expression Encoder template for Silverlight.