问题描述
我已经在Stackoverflow上问过了,但是没有任何答案,非常抱歉.也许我们可以在这里废弃它.
我正在使用WPF MediaElement和OnButton播放视频,单击它会打开第二个窗口(我使用Screens.AllScreens [1]将其移动到第二个监视器).在第二个窗口中,我创建了一个新的mediaelement实例,并将值从mediaelement1.position放入mediaelemnt2.position.现在我在第二个窗口中有一秒钟的延迟...
有办法解决吗?
感谢您的帮助.
Hi,
I''ve already asked at Stackoverflow, but without any answers, so sorry for double post.
Maybe we can disuss it here.
I''m playing a video with the WPF MediaElement and OnButton Click it opens a second window (I move it with Screens.AllScreens[1] to my second monitor). On second window I''ve created a new instance of mediaelement and put the value from mediaelement1.position to mediaelemnt2.position. Now I have a one second delay in my second window ...
Is there a way to handle this?
Thanks for help
推荐答案
<Window ...>
<Window.Resources>
<VisualBrush x:Key="Media" Stretch="Uniform">
<VisualBrush.Visual>
<MediaElement Source="PathToMedia"/>
</VisualBrush.Visual>
</VisualBrush>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Rectangle Fill="{StaticResource Media}"/>
<Button Click="Button_Click" Grid.Row="1" Content="Click me!"/>
</Grid>
</Window>
Window1.xaml.cs
Window1.xaml.cs
private void Button_Click(object sender, RoutedEventArgs e)
{
new Window2(Resources["Media"] as VisualBrush).Show();
}
Window2.xaml
Window2.xaml
<Window ...>
<Rectangle Name="display"/>
</Window>
Window2.xaml.cs
Window2.xaml.cs
public Window2(VisualBrush visualBrush)
{
InitializeComponent();
display.Fill = visualBrush;
}
这篇关于将WPF MediaElement视频与第二个窗口同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!