Manipulation events of MediaElement not fire when on FullWindows mode

筅森魡賤 提交于 2019-12-12 04:08:04

问题


When I set player not in fullscreen (player.IsFullWindows = false), event work normally but when change player to full screen all manipulation event not work. Anyone have solution?

                <MediaElement Name="player"
                              Margin="10,5" ManipulationCompleted="player_ManipulationCompleted"
                              ManipulationDelta="Grid_ManipulationDelta"
                              ManipulationMode="TranslateX"
                              >

回答1:


I can reproduce this scenario by enabling both the IsFullWindow="True" and the AreTransportControlsEnabled="True". I think it makes sense, because when we are in the Full Window mode, it will go to the new layer named FullWindowMediaRoot instead of the MediaElement. Inside the FullWindowMediaRoot, it is the MediaTransportControls. You can see that clearly by using the Live Visual Tree as following:

So when we are in the Full Window mode, we need to handle the manipulation event of the TransportControls instead of the manipulation event of the MediaElement as following:

public MainPage()
    {
        this.InitializeComponent();
        player.TransportControls.ManipulationMode = ManipulationModes.TranslateX;
        player.TransportControls.ManipulationDelta += TransportControls_ManipulationDelta;
        player.TransportControls.ManipulationCompleted += TransportControls_ManipulationCompleted;

    }

    private void TransportControls_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
    {

    }

    private void TransportControls_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    {

    }

Thanks.



来源:https://stackoverflow.com/questions/36181933/manipulation-events-of-mediaelement-not-fire-when-on-fullwindows-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!