--- title: "How to: Play Media using a VideoDrawing" ms.date: "03/30/2017" helpviewer_keywords: - "playback of media [WPF]" - "classes [WPF], MediaPlayer" ms.assetid: 165d47ed-22ce-4ded-aa6a-aa9b7467de87 --- # How to: Play Media using a VideoDrawing To play an audio or video file, you use a and a . There are two ways to load and play media. The first is to use a and a by themselves, and the second way is to create your own to use with the and . > [!NOTE] > When distributing media with your application, you cannot use a media file as a project resource, like you would an image. In your project file, you must instead set the media type to `Content` and set `CopyToOutputDirectory` to `PreserveNewest` or `Always`. ## Example The following example uses a and a to play a video file once. [!code-csharp[DrawingMiscSnippets_snip#VideoDrawingExampleInline](~/samples/snippets/csharp/VS_Snippets_Wpf/DrawingMiscSnippets_snip/CSharp/VideoDrawingExample.cs#videodrawingexampleinline)] To gain additional timing control over the media, use a with the and objects. The enables you to specify whether the video should repeat. ## Example The following example uses a with the and objects to play a video repeatedly. [!code-csharp[DrawingMiscSnippets_snip#RepeatingVideoDrawingExampleInline](~/samples/snippets/csharp/VS_Snippets_Wpf/DrawingMiscSnippets_snip/CSharp/VideoDrawingExample.cs#repeatingvideodrawingexampleinline)] Note that, when you use a , you use the interactive returned from the property of the to control media playback instead of the interactive methods of . ## See also - - [Drawing Objects Overview](drawing-objects-overview.md)