Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> Windows Phone >> MediaElement Control in Windows 7 Phone Development
MediaElement Control in Windows 7 Phone Development
MediaElement Control in Windows 7 Phone Development


by Arun Singh on 4/13/2012 3:49:20 PM

Views: 1814       Comments: 0

MediaElement Control in Windows 7 Phone Development

When beginning a media-based application for Windows Phone, perhaps the easiest thing to do is to use the Silverlight MediaElement control. With just a few lines of code, you can easily play or stream video in your Windows Phone Application. This article is going to explain how to use MediaElement control in Windows 7 Phone development.

Getting started:

1.       Open Visual Studio

2.       Create new Silverlight Windows 7 Phone Development Project

3.       Enter your project Name

4.       Click on button ‘Ok’

MediaElement Control in Windows 7 Phone Development

Now drag and drop MediaElement control form toolbox into MainPage.xaml design page; after doing this set media path by selecting Source property of MediaElement control.

MediaElement Control in Windows 7 Phone Development

Now write down the following code to build this layout;

Code of ‘MainPage.xaml’:

<!--LayoutRoot is the root grid where all page content is placed-->

    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Grid.RowDefinitions>

            <RowDefinition Height="Auto"/>

            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>

 

        <!--TitlePanel contains the name of the application and page title-->

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

            <TextBlock x:Name="ApplicationTitle" Text="My Application" Style="{StaticResource PhoneTextNormalStyle}"/>

            <TextBlock x:Name="PageTitle" Text="MediaElement Demo" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>

        </StackPanel>

 

        <!--ContentPanel - place additional content here-->

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

            <MediaElement Height="433" HorizontalAlignment="Left" Margin="12,0,0,140" Name="mdElementDemo" VerticalAlignment="Bottom" Width="438" />

        </Grid>

    </Grid>

 

Code of ‘MainPage.xaml.cs’:

using System;

using System.Windows;

using Microsoft.Phone.Controls;

using Microsoft.Phone.Tasks;

 

namespace MediaElementDemo

{

    public partial class MainPage : PhoneApplicationPage

    {

        // Constructor

        public MainPage()

        {

            InitializeComponent();

 

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

        }

 

        void MainPage_Loaded(object sender, RoutedEventArgs e)

        {

            MediaPlayerLauncher launcher = new MediaPlayerLauncher();

 

            launcher.Media = new Uri("http://www.robtowns.com/music/blind_willie.mp3", UriKind.RelativeOrAbsolute);

            launcher.Controls = MediaPlaybackControls.All;

            launcher.Show();

        }

 

      

    }

}

 

 

Now execute your program then following output window will be appearing.

MediaElement Control in Windows 7 Phone Development

MediaElement Control in Windows 7 Phone Development

This is the complete description about Media Control in Windows Phone 7. I hope you will be enjoying it. Thanks for reading this article.

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Arun SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 2712
Advertisement
MindStick Cleaner
Advertise with Us
  
Copyright © 2013MindStick. All Rights Reserved.