我有一个视频控制来播放我的视频,但我无法恢复我的视频;你能帮我吗?媒体元素; 非常感谢你
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 = new Uri(MediaPathTextBox.Text);
VideoControl.Play();
}
void PauseClick(object sender, EventArgs e)
{
VideoControl.Pause();
}
void StopClick(object sender, EventArgs e)
{
VideoControl.Stop();
}
}
////////////////////////////////////// 我的xaml代码在这里
<TextBox Height="20" Margin="10,7,134,0" Name="MediaPathTextBox" VerticalAlignment="Top" ></TextBox>
<Button Height="20" HorizontalAlignment="Right" Margin="0,6,14,0" Name="BrowseButton"
VerticalAlignment="Top" Width="94" Click="BrowseClick">
Browse Media
</Button>
<MediaElement Canvas.Left="20" Canvas.Top ="40"
Name="VideoControl" LoadedBehavior="Manual" UnloadedBehavior="Stop" >
</MediaElement>
<Button Height="23" HorizontalAlignment="Left" Margin="15,0,0,13"
Name="PlayButton" VerticalAlignment="Bottom" Width="75"
Click="PlayClick">
Play</Button>
<Button Height="23" HorizontalAlignment="Left" Margin="103,0,0,13"
Name="PauseButton" VerticalAlignment="Bottom" Width="75"
Click="PauseClick">
Pause</Button>
<Button Height="23" Margin="191,0,186,13" Name="StopButton"
VerticalAlignment="Bottom" Click="StopClick">
Stop</Button>
答案 0 :(得分:1)
只需在简历按钮下使用视频control.play();
void resumeClick(object sender, EventArgs e)
{
// VideoControl.Stop();
VideoControl.Play();
}