Media Player

Play videos in your game

Reference the library

C#
using CI.WSANative.Media;

Create the media player

You must have the internet client capability enabled in the app manifest if you are playing content from the internet

Uri supports either a web url or the path to an embedded file starting with ms-appx:///

C#
WSANativeMediaPlayer.Create(new WSAMediaPlayerSettings() { HorizontalPlacement = WSAHorizontalPlacement.Centre, VerticalPlacement = WSAVerticalPlacement.Centre, Height = 700, Width = 700, AreTransportControlsEnabled = true, AutoPlay = true, IsFullWindow = false, Uri = new Uri("https://cdn.flowplayer.com/a30bd6bc-f98b-47bc-abf5-97633d4faea0/hls/de3f6ca7-2db3-4689-8160-0f574a5996ad/playlist.m3u8") });

Destroy the media player

C#
WSANativeMediaPlayer.Destroy();

Play

C#
WSANativeMediaPlayer.Play();

Pause

C#
WSANativeMediaPlayer.Pause();

Set the playback position

C#
WSANativeMediaPlayer.SetPosition(TimeSpan.FromSeconds(30));

Get the duration of the media

C#
var duration = WSANativeMediaPlayer.Duration;

Events

Listen to these events for info about the media players lifecycle

C#
WSANativeMediaPlayer.MediaOpened
C#
WSANativeMediaPlayer.MediaEnded
C#
WSANativeMediaPlayer.MediaFailed