[英]C# UWP MediaPlayerElement Interactive Mode Event?
Microsoft Player Framework had an event for OnIsInteractiveChanged so we could determine if the controls were being displayed. Microsoft Player框架有一个OnIsInteractiveChanged事件,因此我们可以确定是否显示控件。 I can't seem to find a similar event for MediaPlayerElement. 我似乎找不到MediaPlayerElement的类似事件。 Is there a similar event that gets fired when the controls visible? 控件可见时是否会触发类似事件?
s there a similar event that gets fired when the controls visible? 控件可见时是否会触发类似事件?
Currently, there is no such event to determine if the controls were being displayed. 当前,尚无此类事件来确定控件是否正在显示。 It only provide a simple way to manage this with one new property ShowAndHideAutomatically
and two new methods Show()
and Hide()
. 它仅通过一种新属性ShowAndHideAutomatically
以及两种新方法Show()
和Hide()
提供了一种简单的方法来进行管理。
If you do want this feature you could custom MediaTransportControls
and create a timer to determine the controls were being displayed. 如果确实要使用此功能,则可以自定义MediaTransportControls
并创建一个计时器以确定正在显示的控件。
You will found ControlPanelFadeIn
storyboard to make the controls fade in. If control panel fade in, the ControlPanel_ControlPanelVisibilityStates_Border
opacity will turn to 0. So you could create a timer to determine this value. 您会发现ControlPanelFadeIn
故事板可以使控件淡入。如果控件面板淡入, ControlPanel_ControlPanelVisibilityStates_Border
不透明度将变为0。因此,您可以创建一个计时器来确定该值。
public sealed class CustomMediaTransportControls : MediaTransportControls
{
private DispatcherTimer KeepTransportControlsVisibleTimer;
private Border ControlPanelGrid;
public CustomMediaTransportControls()
{
this.DefaultStyleKey = typeof(CustomMediaTransportControls);
KeepTransportControlsVisibleTimer = new DispatcherTimer();
KeepTransportControlsVisibleTimer.Interval = TimeSpan.FromMilliseconds(200);
KeepTransportControlsVisibleTimer.Tick += KeepTransportControlsVisibleTimer_Tick;
KeepTransportControlsVisibleTimer.Start();
}
private void KeepTransportControlsVisibleTimer_Tick(object sender, object e)
{
var opacity = ControlPanelGrid.Opacity;
System.Diagnostics.Debug.WriteLine(opacity);
// do some stuff
}
//overriding OnApplyTemplate
protected override void OnApplyTemplate()
{
ControlPanelGrid = GetTemplateChild("ControlPanel_ControlPanelVisibilityStates_Border") as Border;
base.OnApplyTemplate();
}
}
For creatting custom transport controls, please check this . 要创建自定义运输控件,请检查此 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.