WPF C# Tutorial

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="AnimatedVideoWindow" Height="450" Width="400">
  
    
                            RepeatBehavior="Forever">
          To="360" Duration="0:0:2" RepeatBehavior="Forever">
    
  

  
    
      
        
          
        

      
      
        
          
        

            
    

      Play (Declarative)
      Stop (Declarative)
      Play (Code)
    
      
        
      

    
  


//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
namespace SoundAndVideo
{
    public partial class AnimatedVideoWindow : System.Windows.Window
    {
        public AnimatedVideoWindow()
        {
            InitializeComponent();
        }
        private void cmdPlayCode_Click(object sender, RoutedEventArgs e)
        {
            MediaTimeline timeline = new MediaTimeline(new Uri("test.mpg", UriKind.Relative));            
            timeline.RepeatBehavior = RepeatBehavior.Forever;
            MediaClock clock = timeline.CreateClock();
            MediaPlayer player = new MediaPlayer();
            player.Clock = clock;
            VideoDrawing videoDrawing = new VideoDrawing();
            videoDrawing.Rect = new Rect(150, 0, 100, 100);
            videoDrawing.Player = player;
            DrawingBrush brush = new DrawingBrush(videoDrawing);
            this.Background = brush;
            clock.Controller.Begin();
        }
    }
}