//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();
}
}
}