任何人都可以帮助我了解如何使用UWP MediaElement.SetPlaybackSource吗?
我浏览了this链接,但无法弄清楚/了解此方法的用法。也没有在MSDN或网络上提供的任何示例。谢谢!
答案 0 :(得分:0)
//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);
}