1

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!!

Kenneth Witham
  • 174
  • 2
  • 15
  • You [can't run universal apps on earlier versions of Windows](http://stackoverflow.com/questions/30317848/run-windows-10-universal-apps-on-windows-8-1) – stuartd Dec 14 '16 at 16:34
  • Sorry, I meant like version 5011 or original release of Windows 10, updating question – Kenneth Witham Dec 14 '16 at 16:35
  • [MediaElement](https://msdn.microsoft.com/library/windows/apps/br242926)? – stuartd Dec 14 '16 at 16:38
  • Should I just make a MediaElement in the else statement and add it to the frame like I did the MediaPlayerElement? I access multiple parts of the MediaPlayer in other parts of the program (source, volume, etc.). Will I need to handle doing these differently each time I want to use them then? – Kenneth Witham Dec 14 '16 at 16:42
  • I know MediaPlayer was available in all versions of Windows 10. Is there any way to show a MediaPlayer on a UI before MediaPlayerElement? – Kenneth Witham Dec 14 '16 at 17:11

1 Answers1

1

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

mm8
  • 163,881
  • 10
  • 57
  • 88