UWP MediaPlayerElement Backwards Compatibility

528 views Asked by At

So I am hoping this will be an easy solution. I am currently designing a media app that uses a MediaPlayerElement. I am developing on Windows 14393 (Anniversary Update) I have read that the MediaPlaerElement is only supported in this version but I would like to support older versions of Windows (Build 10586 or 10240) as well. What would be the best way to do this? I have started in my code below but don't know what I should use to display the video in older versions.

Creation Code in frame constructor:

        if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3))
        {
            MediaPlayerElement newPlayer = new MediaPlayerElement()
            {
                AreTransportControlsEnabled = true,
                Stretch = Stretch.Uniform,
                AutoPlay = true,
                IsRightTapEnabled = false
            };
            newPlayer.TransportControls.IsZoomButtonVisible = false;
            newPlayer.TransportControls.IsZoomButtonVisible = false;
            Player = newPlayer.MediaPlayer;
            newPlayer.TransportControls.DoubleTapped += SingleMediaElement_DoubleTapped;
            this.MainGrid.Children.Add(newPlayer);
        }
        else
        {
            //Windows.Media.Playback.MediaPlayer oldPLayer = new Windows.Media.Playback.MediaPlayer()
            //{
            //    AutoPlay = true
            //};
        }

What would be the best way to create and use a video player in my app on older versions of windows (ideally UniversalAPI 1.0)?

Thanks!!

1

There are 1 answers

1
mm8 On BEST ANSWER

What would be the best way to create and use a video player in my app on older versions of windows (ideally UniversalAPI 1.0)?

Using a MediaElement:

<MediaElement x:Name="me" Source="ms-appx:///video.wmv" AutoPlay="True" />

MediaElement class: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.mediaelement.aspx