zoukankan      html  css  js  c++  java
  • WP7备注(24)(ApplicationBar|MediaElement)

    ApplicationBar常规用法:

    <shell:ApplicationBar IsVisible="False">

    <shell:ApplicationBarIconButton
    IconUri="Images/appbar.transport.pause.rest.png"
    Text="Pause"
    IsEnabled="False"
    Click="OnAppBarPauseClick" />

    (this.ApplicationBar.Buttons[1] as ApplicationBarIconButton).IsEnabled = false;

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

    MediaElement控制实例:

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <MediaElement Name="mediaElement"
    Source="http://www.charlespetzold.com/Media/Walrus.wmv"
    AutoPlay="False"
    MediaOpened="OnMediaElementMediaOpened"
    MediaFailed="OnMediaElementMediaFailed"
    CurrentStateChanged="OnMediaElementCurrentStateChanged" />
    <TextBlock Name="statusText"
    HorizontalAlignment="Left"
    VerticalAlignment="Bottom" />
    <TextBlock Name="errorText"
    HorizontalAlignment="Right"
    VerticalAlignment="Bottom"
    TextWrapping="Wrap" />
    </Grid>
    public MainPage()
    {
    InitializeComponent();
    // Re-assign names already in the XAML file
    appbarRewindButton = this.ApplicationBar.Buttons[0] as ApplicationBarIconButton;
    appbarPlayButton = this.ApplicationBar.Buttons[1] as ApplicationBarIconButton;
    appbarPauseButton = this.ApplicationBar.Buttons[2] as ApplicationBarIconButton;
    appbarEndButton = this.ApplicationBar.Buttons[3] as ApplicationBarIconButton;
    }
    void OnAppbarRewindClick(object sender, EventArgs args)
    {
    mediaElement.Position = TimeSpan.Zero;
    }
    void OnAppbarPlayClick(object sender, EventArgs args)
    {
    mediaElement.Play();
    }
    void OnAppbarPauseClick(object sender, EventArgs args)
    {
    mediaElement.Pause();
    }
    void OnAppbarEndClick(object sender, EventArgs args)
    {
    mediaElement.Position = mediaElement.NaturalDuration.TimeSpan;
    }
    void OnMediaElementMediaFailed(object sender, ExceptionRoutedEventArgs args)
    {
    errorText.Text = args.ErrorException.Message;
    }
    void OnMediaElementMediaOpened(object sender, RoutedEventArgs args)
    {
    appbarRewindButton.IsEnabled = true;
    appbarEndButton.IsEnabled = true;
    }
    void OnMediaElementCurrentStateChanged(object sender, RoutedEventArgs args)
    {
    statusText.Text = mediaElement.CurrentState.ToString();
    if (mediaElement.CurrentState == MediaElementState.Stopped ||
    mediaElement.CurrentState == MediaElementState.Paused)
    {
    appbarPlayButton.IsEnabled = true;
    appbarPauseButton.IsEnabled = false;
    }
    else if (mediaElement.CurrentState == MediaElementState.Playing)
    {
    appbarPlayButton.IsEnabled = false;
    appbarPauseButton.IsEnabled = true;
    }
    }
  • 相关阅读:
    Go语言基础介绍
    webpack教程——css的加载
    Git忽略规则.gitignore梳理
    vue2.0路由-适合刚接触新手简单理解
    JAVA实现DES加密实现详解
    计算机网络: IP地址,子网掩码,网段表示法,默认网关,DNS服务器详解
    Storm:最火的流式处理框架
    神片和神回复
    论C#未来发展
    弄清UTF8和Unicode
  • 原文地址:https://www.cnblogs.com/otomii/p/2032619.html
Copyright © 2011-2022 走看看