如何使用MediaElement.SetPlaybackSource

How to use MediaElement.SetPlaybackSource

任何人都可以帮助我了解如何使用 UWP MediaElement.SetPlaybackSource?

我经历了 this link,但是无法 figure-out/understand 使用此方法。 MSDN 或网络上的其他地方也没有提供任何示例。谢谢!

这里是sample code from MSDN:

//Create a new picker
var filePicker = new Windows.Storage.Pickers.FileOpenPicker();

//Add filetype filters.  In this case wmv and mp4.
filePicker.FileTypeFilter.Add(".wmv");
filePicker.FileTypeFilter.Add(".mp4");
filePicker.FileTypeFilter.Add(".mkv");

//Set picker start location to the video library
filePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;

//Retrieve file from picker
StorageFile file = await filePicker.PickSingleFileAsync();

if (file != null)
{
    mediaSource = MediaSource.CreateFromStorageFile(file);
    mediaElement.SetPlaybackSource(mediaSource);
}