我想用MediaElement播放视频文件,但是运行后没有反应,也没有报错,请问大家有没有遇到过这种情况?
<Window x:Class="WpfApplication3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
<Grid>
<MediaElement Margin="12,12,12,50" Name="mediaElement1" Stretch="Fill" LoadedBehavior="Manual" Source="M\200712190410116728750.mp3" />
<Button Height="23" HorizontalAlignment="Left" Margin="12,0,0,12" Name="button1" VerticalAlignment="Bottom" Width="75" Click="button1_Click">Button</Button>
</Grid>
</Window>...
private void button1_Click(object sender, RoutedEventArgs e)
{
//this.mediaElement1.Source = new Uri(@"d:\res\200712190410116728750.mp3");
this.mediaElement1.Play();
}
<Window x:Class="WpfApplication3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
<Grid>
<MediaElement Margin="12,12,12,50" Name="mediaElement1" Stretch="Fill" LoadedBehavior="Manual" Source="M\200712190410116728750.mp3" />
<Button Height="23" HorizontalAlignment="Left" Margin="12,0,0,12" Name="button1" VerticalAlignment="Bottom" Width="75" Click="button1_Click">Button</Button>
</Grid>
</Window>...
private void button1_Click(object sender, RoutedEventArgs e)
{
//this.mediaElement1.Source = new Uri(@"d:\res\200712190410116728750.mp3");
this.mediaElement1.Play();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货