图像(Image class)放置在SMFPlayer上方(这两个元素都是在代码隐藏中创建的)。图像的 Z 索引是 SMFPlayer + 1 的 Z 索引。根据 SMFPlayer 的播放进度调整图像大小(调整宽度)。
videoPlayer = new SMFPlayer();
videoPlayer.Width = 1920;
videoPlayer.Height = 1080;
videoPlayer.Margin = new Thickness(1920, 0, 0, 0);
PlaylistItem item = new PlaylistItem();
Random r = new Random();
item.MediaSource = new Uri("video.wmv");
item.DeliveryMethod = DeliveryMethods.ProgressiveDownload;
videoPlayer.Playlist.Add(item);
videoPlayer.AutoPlay = true;
videoPlayer.AutoLoad = true;
videoPlayer.IsControlStripVisible = false;
videoPlayer.PlaylistVisibility = FeatureVisibility.Disabled;
videoPlayer.MediaEnded += new EventHandler(player_MediaEnded);
LayoutRoot.Children.Add(videoPlayer);
bar_yellow3 = new Image();
bar_yellow3.Source = new BitmapImage(new Uri("/SMF_ProgressiveDownload1;component/assets/bar_y.png", UriKind.Relative));
bar_yellow3.Width = 775;
bar_yellow3.Height = 34;
bar_yellow3.Margin = new Thickness(2948,1034,0,0);
bar_yellow3.Stretch = Stretch.Fill;
bar_yellow3.VerticalAlignment = VerticalAlignment.Top;
bar_yellow3.HorizontalAlignment = HorizontalAlignment.Left;
LayoutRoot.Children.Add(bar_yellow3);
但是,当播放进度小于 20% 时,图像会随机闪烁。当SMFPlayer设置为不可见(可见性折叠)时,图像是正常的。
我尝试调用图像的更新函数,即:bar_yellow3。更新布局();但是该方法不能解决闪烁问题。
有什么解决办法吗?
尝试使用效果(Shazzam 会帮助你)而不是使用 Z 顺序。