c# - 如何使用 MediaElement.SetPlaybackSource

标签 c# winrt-xaml uwp-xaml

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

我经历了this链接,但是无法弄清楚/理解此方法的用法。 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);
}

关于c# - 如何使用 MediaElement.SetPlaybackSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37573641/

相关文章:

c# - 捕获不相关进程的输出

xaml - 带有 XAML 元素 header 的 ScrollViewer 中的 WebView

windows-8 - 如何使用 C++ 从资源图像为 Windows Metro 应用程序创建 WriteableBitmap?

c# - UWP App 中的 GridViewItem IsSelected 绑定(bind)

c# - 如何使用 XAML 语法在 UWP 类库中引用 Assets

c# - ASP.NET MVC4 Web API MediaTypeFormatter Converter 将 XElement 转换为 JSON

c# - 如何判断一个进程是否已经启动但还没有退出?

c# - 玩字节...需要从 Java 转换为 C#

c# - XAML : Setting the value of Storyboard animation from code behind

xaml - 如何删除 UWP 中分组 ListView 的边距/填充并启用全宽?