uwp 之多媒体开发

xml code

-----------------------------------------------------

<Page

    x:Class="MyApp.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:MyApp"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>

        <MediaElement Source="wpa.mp4" AreTransportControlsEnabled="True"/>

    </Grid>

</Page>

C#   code

------------------------------------------------------------------------------------------------

 public sealed partial class MainPage : Page

    {

        public MainPage()

        {

            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

        }

        /// <summary>

        /// 在此页将要在 Frame 中显示时进行调用。

        /// </summary>

        /// <param name="e">描述如何访问此页的事件数据。

        /// 此参数通常用于配置页。</param>

        protected override void OnNavigatedTo(NavigationEventArgs e)

        {

            // TODO: 准备此处显示的页面。

            // TODO: 如果您的应用程序包含多个页面,请确保

            // 通过注册以下事件来处理硬件“后退”按钮:

            // Windows.Phone.UI.Input.HardwareButtons.BackPressed 事件。

            // 如果使用由某些模板提供的 NavigationHelper,

            // 则系统会为您处理该事件。

        }

    }

原文地址:https://www.cnblogs.com/bruce1992/p/14222737.html