Different Windows Phone (14)

Source: Internet
Author: User
Tags xmlns


Media Audio player, video player, integrated with Windows Phone's music and video Center



Introduced



Special media for Windows Phone 7.5 (SDK 7.1)



Audio player



Video player



Integration with Windows Phone's music and video Center



Example



1. Demo Audio player



Audio.xaml




<phone: PhoneApplicationPage
    x: Class = "Demo.Media.Audio"
    xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns: phone = "clr-namespace: Microsoft.Phone.Controls; assembly = Microsoft.Phone"
    xmlns: shell = "clr-namespace: Microsoft.Phone.Shell; assembly = Microsoft.Phone"
    xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
    xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily = "{StaticResource PhoneFontFamilyNormal}"
    FontSize = "{StaticResource PhoneFontSizeNormal}"
    Foreground = "{StaticResource PhoneForegroundBrush}"
    SupportedOrientations = "Portrait" Orientation = "Portrait"
    mc: Ignorable = "d" d: DesignHeight = "768" d: DesignWidth = "480"
    shell: SystemTray.IsVisible = "True">
   
    <Grid x: Name = "LayoutRoot" Background = "Transparent">
        <StackPanel Orientation = "Vertical">
            <MediaElement x: Name = "mediaElement" Source = "Assets / SuperMario.mp3" AutoPlay = "False" />
   
            <Button x: Name = "btnPlay" Content = "Play" Click = "btnPlay_Click" />
            <Button x: Name = "btnPause" Content = "Pause" Click = "btnPause_Click" />
               
            <TextBlock x: Name = "lblStatus" />
        </ StackPanel>
    </ Grid>
   
</ phone: PhoneApplicationPage>


Audio.xaml.cs


/ *
 * MediaElement-for playing video or audio, either local address or remote address
 * Refer to: http://msdn.microsoft.com/en-us/library/ff462087(v=vs.92) for the supported encoding formats
 *
 * For detailed description of MediaElement, please see: http://www.cnblogs.com/webabcd/archive/2008/12/01/1344632.html
 * For the launcher method, please refer to: MediaPlayerLauncher in http://www.cnblogs.com/webabcd/archive/2012/06/14/2548776.html
 *
 * XNA playback audio see: http://www.cnblogs.com/webabcd/archive/2011/07/11/2102713.html
 * /
   
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
   
namespace Demo.Media
{
    public partial class Audio: PhoneApplicationPage
    {
        public Audio ()
        {
            InitializeComponent ();
   
            mediaElement.CurrentStateChanged + = new RoutedEventHandler (mediaElement_CurrentStateChanged);
        }
   
        void mediaElement_CurrentStateChanged (object sender, RoutedEventArgs e)
        {
            // Display the current state of MediaElement
            lblStatus.Text = mediaElement.CurrentState.ToString ();
        }
   
        private void btnPlay_Click (object sender, RoutedEventArgs e)
        {
            // play
            mediaElement.Play ();
        }
   
        private void btnPause_Click (object sender, RoutedEventArgs e)
        {
            // time out 
            mediaElement.Pause ();
        }
    }
} 




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.