Media player for Windows 7 Mobile


This article will give step to step illustration of creating a simple media application for Windows 7 mobile.

Step 1

Create a new Windows Phone Application. From Silverlight for Windows Phone tab select Windows Phone Application project type.


Step 2

Design page.

  1. Divide content grid in two rows
  2. In first row put a media element control
  3. In second row put a button.








mc:Ignorable=”d” d:DesignWidth=”480″ d:DesignHeight=”800″

FontFamily=”{StaticResource PhoneFontFamilyNormal}”

FontSize=”{StaticResource PhoneFontSizeNormal}”

Foreground=”{StaticResource PhoneForegroundBrush}”>

<Grid x:Name=”LayoutRoot” Background=”{StaticResource PhoneBackgroundBrush}”>


<RowDefinition Height=”Auto”/>

<RowDefinition Height=”*”/>


<!–TitleGrid is the name of the application and page title–>

<Grid x:Name=”TitleGrid” Grid.Row=”0″>

<TextBlock Text=”Windows 7 phone” x:Name=”textBlockPageTitle” Style=”{StaticResource PhoneTextPageTitle1Style}”/>

<TextBlock Text=”Media” x:Name=”textBlockListTitle” Style=”{StaticResource PhoneTextPageTitle2Style}”/>


<!–ContentGrid is empty. Place new content here–>

<Grid x:Name=”ContentGrid” Grid.Row=”1″>


<RowDefinition Height=”*” />

<RowDefinition Height=”Auto” />
<Button x:Name=”btnPlay” Content=”Play” Height=”50″ Width=”100″ Grid.Row=”1″ />

<MediaElement x:Name=”mediactrl” HorizontalAlignment=”Stretch” VerticalAlignment=”Stretch” Stretch=”Uniform” Grid.Row=”0″/>



Step 3

Right click on project and add an existing .wmv in project. I am adding a.wmv file here.

Step 4

Now in code behind just write below code to play the media file

    1 using System;

    2 using System.Collections.Generic;

    3 using System.Linq;

    4 using System.Net;

    5 using System.Windows;

    6 using System.Windows.Controls;

    7 using System.Windows.Documents;

    8 using System.Windows.Input;

    9 using System.Windows.Media;

   10 using System.Windows.Media.Animation;

   11 using System.Windows.Shapes;

   12 using Microsoft.Phone.Controls;


   14 namespace PhotoApplication

   15 {

   16     public partial class MainPage : PhoneApplicationPage

   17     {

   18         public MainPage()

   19         {

   20             InitializeComponent();


   22             SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

   23             btnPlay.Click += new RoutedEventHandler(btnPlay_Click);

   24         }


   26         void btnPlay_Click(object sender, RoutedEventArgs e)

   27         {


   29             mediactrl.Source = new Uri(“a.wmv”, UriKind.Relative);

   30             mediactrl.Play();

   31         }



   34     }

   35 }

Press F5 to get output


I hope this article was useful. Thanks for reading. Happy coding.

2 responses to “Media player for Windows 7 Mobile”

  1. I found this blog post very useful, thank for sharing. I was trying to develop silverlight game application which can run on iPhone, do you have any example application.

    Thanks for step by step making me understand and work with mobile applications.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at