我正在创建一个视频播放器,我需要使用近50个矩形来显示相同的视频
使用视觉刷。问题是它播放了一段时间没有崩溃大部分时间应用程序崩溃和显示
故障模块wpfgfx_v0400.dll,填充矩形的帧速率下降。
谢谢。代码:
string SourceFile;
MediaElement Element = new MediaElement();
public void mediaaaaa( string PathFile)
{
SourceFile = PathFile;
Element.LoadedBehavior = MediaState.Play;
Element.BeginInit();
Element.Source = new Uri(PathFile, UriKind.RelativeOrAbsolute);
Element.EndInit();
Element.UnloadedBehavior = MediaState.Close;
StackPanel dd = new StackPanel();
dd.Children.Add(Element);
Element.MediaEnded += new RoutedEventHandler(Element_MediaEnded);
WrapPanel wrap = new WrapPanel();
foreach (MediaElement item in dd.Children)
{
for (int i = 0; i < 50; i++)
{
Rectangle Vis = new Rectangle();
Vis.Fill = new VisualBrush(item);
Vis.Width = 200;
Vis.Height = 200;
wrap.Children.Add(Vis);
}
}
canvas.Children.Clear();
canvas.Children.Add(wrap);
}
void Element_MediaEnded(object sender, RoutedEventArgs e)
{
Element.Source = new Uri(SourceFile);
}