<TextBoxHeight="20"Margin="10,7,134,0"Name="MediaPathTextBox"VerticalAlignment="Top" ></TextBox>
<ButtonHeight="20"HorizontalAlignment="Right"Margin="0,6,14,0"Name="BrowseButton"
VerticalAlignment="Top"Width="94"Click="BrowseClick">
Browse Media
</Button>
<MediaElementCanvas.Left="20"Canvas.Top ="40"
Name="VideoControl"LoadedBehavior="Manual"UnloadedBehavior="Stop" >
</MediaElement>
<ButtonHeight="23"HorizontalAlignment="Left"Margin="15,0,0,13"
Name="PlayButton"VerticalAlignment="Bottom"Width="75"
Click="PlayClick">
Play</Button>
<ButtonHeight="23"HorizontalAlignment="Left"Margin="103,0,0,13"
Name="PauseButton"VerticalAlignment="Bottom"Width="75"
Click="PauseClick">
Pause</Button>
<ButtonHeight="23"Margin="191,0,186,13"Name="StopButton"
VerticalAlignment="Bottom" Click="StopClick">
Stop</Button>
</Grid>
public Window1()
{
InitializeComponent();
VideoControl.Volume = 100;
VideoControl.Width = 440;
VideoControl.Height = 280;
}
void BrowseClick(Object sender, EventArgs e)
{
OpenFileDialog openDlg =new OpenFileDialog();
openDlg.InitialDirectory = @"c:\";
openDlg.ShowDialog();
MediaPathTextBox.Text = openDlg.FileName;
}
void PlayClick(object sender, EventArgs e)
{
if (MediaPathTextBox.Text.Length <= 0)
{
System.Windows.Forms.MessageBox.Show("Enter a valid media file");
return;
}
VideoControl.Source = newUri(MediaPathTextBox.Text);
VideoControl.Play();
}
void PauseClick(object sender, EventArgs e)
{
VideoControl.Pause();
}
void StopClick(object sender, EventArgs e)
{
VideoControl.Stop();
} |