I am following the codes from
http://blogs.msdn.com/b/tolong/archive/2006/12/27/how-to-embed-video-into-wpf-application.aspx
I can run and execute the application from Visual Studio itself, it is able to load in the static image (test.JPG), and upon click the Play button, it is able to play the test.AVI video.
However, if I run the XAML Browser Application file from the Release directory, it is able to open up the applicaiton in the browser, and display the static image (test.JPG), and upon the click on the Play button, the video test.AVI does NOTcomes out.
What are the settings required? Thanks.
Codes are as below:
<Page x:Class="XAMLBrowserApplication1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Image Name="VideoPreview" Source="Images/test.JPG" Grid.Row="0"/>
<MediaElement Name="redangVideo" Source="test.AVI" LoadedBehavior="Manual" Grid.Row="0"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Click="PlayVideo">Play</Button>
<Button Click="PauseVideo">Pause</Button>
<Button Click="StopVideo">Stop</Button>
</StackPanel>
</Grid>
</Page>
using System;
using System.Collections.Generic;
using System.Linq;
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.Navigation;
using System.Windows.Shapes;
namespace XAMLBrowserApplication1
{
/// <summary>
/// Interaction logic for Page1.xaml
/// </summary>
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
public void PlayVideo(object sender, RoutedEventArgs e)
{
VideoPreview.Visibility = Visibility.Collapsed;
redangVideo.Visibility = Visibility.Visible;
redangVideo.Play();
}
public void PauseVideo(object sender, RoutedEventArgs e)
{
VideoPreview.Visibility = Visibility.Collapsed;
redangVideo.Visibility = Visibility.Visible;
redangVideo.Pause();
}
public void StopVideo(object sender, RoutedEventArgs e)
{
VideoPreview.Visibility = Visibility.Collapsed;
redangVideo.Visibility = Visibility.Visible;
redangVideo.Stop();
}
}
}

0 answers