Microsoft Player Framework had an event for OnIsInteractiveChanged so we could determine if the controls were being displayed. I can't seem to find a similar event for 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()
.
If you do want this feature you could custom MediaTransportControls
and create a timer to determine the controls were being displayed.
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.
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.