ASP.Net Web API Service in Windows Phone: Part 4 of Many

Creating First HTTP Service using ASP.NET Web API: Part1 of Many

Consuming ASP.NET Web API Service using HttpClient: Part2 of Many

How to Self-Host ASP.Net Web API: Part 3 of Many

In this post we will consume ASP.Net Web API HTTP Service in Windows Phone Application. If you do not specify header information in HTTP request then by default ASP.Net Web API service returns JSON data. So essentially there are three steps involved in consuming HTTP Service from ASP.Net Web API in Windows Phone Application.

  1. Make a HTTP Request
  2. Read data from HTTP Response
  3. Parse returned JSON data and bind data to data bound control

In this post we are going to consume service created in this POST

I have created a Windows Phone Application by choosing target framework 7.1. We are going to display Bloggers Data returned from ASP.Net Web API service in a ListView. Essentially we are going to consume a JSON Data from a HTTP Service. For that add below references in the project.

image

We are going to de-serialize JSON data using DataContractJsonSerializer class. We need to create a class at client side representing Bloggers entity from the service. Let us create a class called BloggersClient. We will de-serialize JSON data returning from the HTTP service in this object of this class.


namespace WindowsPhoneClient
{
public class BloggersClient
{
public string Id { get; set; }
public string Name { get; set; }
public string AreaOfIntrest { get; set; }

}
}

Once the client class is in placed add following references,

image

We are going to download JSON data from ASP.Net Web API service using WebClient class. Make sure that you are passing URL of your HTTP Service.

image

In the completed event, we will parse returned JSON using DataContractJsonSerializer class. In following code,

  • Creating MemoryStream form returned result
  • Creating object to de-serialize the returned JSON data
  • Reading de-serialized data object in List of BloggersClient
  • Setting List of BloggerClient as ItemSource of ListBox. On the XAML we have put a ListBox with name lstBloggers.

image

Code behind to load data from ASP.Net Web API HTTP Service on page load of the application and s display in ListBox is as following


using System;
using System.Collections.Generic;
using System.Net;
using Microsoft.Phone.Controls;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;

namespace WindowsPhoneClient
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
WebClient proxy = new WebClient();
proxy.DownloadStringCompleted +=
new DownloadStringCompletedEventHandler(proxy_DownloadStringCompleted);
proxy.DownloadStringAsync(new Uri("http://localhost:39192/api/Bloggers"));
}

void proxy_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Stream s = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<BloggersClient>));
List<BloggersClient> result = (List<BloggersClient>) ser.ReadObject(s);
lstBloggers.ItemsSource = result;
}
}
}

On the XAML, we have put ListBox control do bind data from HTTP Service in the control.

If you are not aware of Data Binding in ListBox then watch a quick Video here


<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="ASP.Net Web API" 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">
<ListBox x:Name="lstBloggers">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextTitle2Style}" />
<TextBlock Text="{Binding AreaOfIntrest}" Style="{StaticResource PhoneTextAccentStyle}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>

Now press F5 to run the application. You should able to get Bloggers detail from ASP.Net Web API service in Windows Phone Application.

image

I hope you find this post useful. Thanks for reading.

Block diagram for Push Notification in Windows Phone 7

Below is the block diagram to Push Notification in Windows Phone 7. There are three types of Push notification

  1. Live Tiles
  2. Toast Notification
  3. Raw Data

 

image

Above diagram is very much self-explanative. There are five steps to perform push notification

  1. Application open a HTTP channel with Microsoft Push Notification Service
  2. Microsoft Push Notification Service returns a unique URI to application
  3. Application sends this URI to custom service usually hosted in Azure
  4. Custom service sends data to send as notification and unique Http Channel URI of application to Microsoft push notification service
  5. Microsoft push notification service identifies application with unique URI and send the notification.

I hope this post is useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Code to Search in Windows Phone 7

In this post I will show you how you could search a particular item on windows phone 7. You can achieve search using launchers. SearchTask class is used to search on Windows Phone 7.

Expected Output

User will type the word to search and click on Search on Phone button. Then application will search on device and web both and give the search result.

image

 

To search an item you will have to use launcher SearchTask. This class is defines as below,

image

You can see in the definition of class that you can set the SearchQuery. SearchQuery is defined as string property in the class.

To work with SearchTask launcher first make instance of this class as below,

clip_image001

Then set the search criteria

clip_image002

In above code we are reading the search criteria from a text box.

For your reference full code to search is as below,


using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
namespace abc
{
public partial class MainPage : PhoneApplicationPage
{

public MainPage()
{
InitializeComponent();

}
private void btnSearch_Click(object sender, RoutedEventArgs e)
{
SearchTask searchonPhoneTask = new SearchTask();
searchonPhoneTask.SearchQuery = txtSearchItem.Text;
searchonPhoneTask.Show();

}
}
}

Design

Design of the page is simple. Application is having one textbox and one button. On click event of the button, it would search the text entered in the textbox.


<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="search phone" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="search on phone" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Button Grid.Row="1" x:Name="btnSearch" Content="Search on Phone" Height="77" Click="btnSearch_Click" Width="auto" Margin="0,23,0,0" />
<TextBox x:Name="txtSearchItem" Width="auto" Height="77" Margin="0,0,0,83" Grid.RowSpan="2" />
</Grid>
</Grid>

This is all you require to search on web and device from your windows phone application. I hope this post is useful. Thanks for reading Smile

 

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Code to Send SMS in Windows Phone 7

Launchers are used to perform task provided by phone operating system. Sending SMS is feature of Windows phone operating system and can be used by Launcher API. SmsCompseTask launcher is used to send SMS. This task class is defined as below,

image

To work with SmsComposeTask, first you need to add namespace of Microsoft.Phone.Task

clip_image001

Then create instance of SmsComposeTask.

clip_image003

Next you need to set required or optional parameter for the launcher task. Required parameters for SmsComposeTask are

  1. To number
  2. Body of SMS

 

So first set the parameter as below,

clip_image001[6]

And SMS body as below,

clip_image002

Last step you need to launch SMS send application provided by operating system. You can show that as below,

clip_image003

If you put all code together and want to send SMS on click event of button then full code will be as below,


using System;
using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace test
{
public partial class MainPage : PhoneApplicationPage
{

public MainPage()
{
InitializeComponent();
}

private void btnSendSMS_Click(object sender, RoutedEventArgs e)
{

SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = "9158153792";
smsComposeTask.Body = "hey I am sending u SMS";
smsComposeTask.Show();

}
}
}

&nbsp;

When you run above code you will get application running as below,

image

When you click on Send SMS button, you will get drafted SMS with TO and body set as below,

image

Now you can either edit the message or set other recipients or send SMS as it is. I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Global Application Bar in Windows Phone 7

In a Windows Phone 7 application, Application Bar is very useful. With as assumption that, you know what is Application Bar? I will discuss with you

  • How Application Bar can be used as static resource?
  • How to make Application Bar as global resource?
  • How to use same Application Bar in multiple pages?

Designing Global Application Bar

To use Application Bar globally in the application, you need to make it as Static Resource. For that open App.xaml and add below code in the resource section,


<Application.Resources>
<shell:ApplicationBar x:Key="MyGlobalAppBar" IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/button1.png" Text="FIRST BUTTON" Click="ApplicationBarIconButton_Click" />
<shell:ApplicationBarIconButton IconUri="/button2.png" Text="SECOND BUTTON" Click="ApplicationBarIconButton_Click_1" />
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="First Menu Item" Click="MenuItem1_Click" />
<shell:ApplicationBarMenuItem Text="Second Meny Item" Click="MenuItem2_Click" />
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</Application.Resources>

There are few points worth discussing

  • I have added as resource two images and setting them as image of the button
  • There are two buttons and two menu items. You are free to change this as of your requirement.
  • Button and menu item click event is being handled on the app.xaml.cs file
  • Key of the global application bar is MyGlobalAppBar . You need to use this key at time of using this application bar. However you are free to give different key and use them accordingly

Code behind for Global Application Bar

In App.Xaml.cs file you need to handle the click event of buttons and menu item as below,


private void ApplicationBarIconButton_Click(object sender, EventArgs e)
{
MessageBox.Show("I am Button 1");
}
private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
{
MessageBox.Show("I am Button 2");
}
private void MenuItem1_Click(object sender, EventArgs e)
{
MessageBox.Show("I am Menu Item 1");
}
private void MenuItem2_Click(object sender, EventArgs e)
{
MessageBox.Show("I am Menu Item 2");
}

&nbsp;

Creating page to use Global Application Bar

You need to set the application bar in each page as below. If you remember MyGlobalAppBar is key of the application bar we created as static resource.

clip_image001

Now when you run the application, you should get below Application Bar on each page you have set it .

image

I hope this post was useful. Thanks for reading and tune in for the next post  Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

System Tray ProgressIndicator in Windows Phone 7.5 or Mango phone

Windows Phone 7.5 (Mango) provides a Progress Indicator on System Tray to show progress of async operation.

clip_image001

ProgressIndicator is a dependency object and can be data bind to the System Tray. ProgressIndicator class is defined as below,

clip_image002

Using ProgressIndicator

To use ProgressIndicator, first you need to add the namespace,

clip_image003

And then create it as below,

clip_image004

On the async operation status you can set visibility to false.

clip_image005

Finally you need to set it to the System Tray or Status Bar as below,

clip_image006

Putting all together below listed source code will give you output shown earlier in the post.


using System.Windows.Media;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace PhoneApp2
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
SystemTray.SetIsVisible(this, true);
SystemTray.SetOpacity(this, 0.5);
SystemTray.SetBackgroundColor(this, Colors.Black);
SystemTray.SetForegroundColor(this, Colors.Blue);
ProgressIndicator progressIndicator = new ProgressIndicator();
progressIndicator.IsVisible = true;
progressIndicator.IsIndeterminate = true;
progressIndicator.Text = "Hey I am Progress Indicator";
SystemTray.SetProgressIndicator(this, progressIndicator);

}
}
}

&nbsp;

In this way you can use system tray progress indicator. I hope this post was useful. Thanks for reading  Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Live Tiles in Windows Phone 7.5 or Mango phone

In Windows Phone 7 Live tiles was only possible through Push notification. However Windows Phone 7.5 (code name: Mango) allows to update, create primary and secondary tiles without push notification. In this post, we will walkthrough on the same.

image

To create and update live tiles essentially you need to work with below classes

StandardTileData and ShellTile

You can get the instance of current tile for application as below,

clip_image002

You can set data for tile as below,

clip_image004

StandardTileData class has following properties. You can set value of these properties to set as data of live tiles.

  1.  public Uri BackBackgroundImage
  2. public string BackContent
  3. public Uri BackgroundImage
  4. public string BackTitle
  5. public int? Count

Update a Live Tile

Below code snippet will update a live tiles with title and count.


using System.Linq;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace liveTiles
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            UpdateLiveTiles();
        }

        private void UpdateLiveTiles()
        {
            ShellTile currentTiles = ShellTile.ActiveTiles.First();
            var tilesUpdatedData = new StandardTileData
                                  {
                                      Title = "Live Tiles ",
                                      Count = 10,
                                      BackTitle ="Back Title"

                                  };

            currentTiles.Update(tilesUpdatedData);

        }
    }
}



Live tile will get updated as below,

image

Create a Live Tile

Below code snippet will create a new live tiles. Creation of live tile is exactly same as updating of live tile but to call Create function.


private void CreateLiveTile()
        {
            var newTile = new StandardTileData()
            {
                Title = "Blogs Update",
                BackgroundImage = new Uri("background.png", UriKind.Relative),
                Count = 42,
            };
            var uri = "/LiveTileUserControl.xaml?state= Live Tile";
            ShellTile.Create(new Uri(uri, UriKind.Relative), newTile);
        }




Important point to note in above code snippet is uri. On click of create live tile user will navigate to given xaml.

clip_image001

Updating created Live Tile

To update a particular tile, first you need to fetch the tile with query string as below,



private void UpdatingCreatedTile()
        {
            var uri = new Uri("/LiveTileUserControl.xaml?state= Live Tile", UriKind.Relative);
            ShellTile  tileToUpdate = ShellTile.ActiveTiles.Where(t => t.NavigationUri == uri).FirstOrDefault();
            var tilesUpdatedData = new StandardTileData
            {
                Title = "Created Tiles Updated ",
                Count = 45,
                BackTitle = "Back Title"

            };

            tileToUpdate.Update(tilesUpdatedData);

        }


Tile will get updated as below,

clip_image001[6]

This was all about basic of live tiles in windows phone 7.5 without using push notification.

I hope this post was useful. Thanks for reading Smile

Setting the Start page in Windows Phone 7 application

Very often I see people struggling in setting start page for Windows Phone 7 application. By default MainPage.xaml serve as start page.

image

If you have many xaml in phone application you are creating like below,

image

Now you have three xaml in Windows Phone application project. If you want to set Page2.xaml as start page then open files WMAppManifest.xml from Properties folder in solution explorer.

 

image

 

In XML file change the default task Navigation attribute to Page2.xamlimage

 

Smooth Streaming on Windows Phone 7

Read Smooth Streaming in Silverlight here

This post is walkthrough on enabling smooth streaming of media over IIS and then stream over Windows Phone 7 client. There are very good documentation available on IIS official site to have a better understanding of smooth streaming. So I am not touching theoretical concept behind smooth streaming in this post. However I have shown steps by steps to enable smooth streaming of media over IIS then to stream over Windows Phone 7 client.

imageimage

Essentially there are four majors steps you need to do

  1. Enable Smooth Streaming on IIS
  2. Encode Media File .There is a point to be noted here that Windows Phone 7 [at time of writing this post] does not support variable bit rate of streaming. It does support only VC-IIS Smooth Streaming -480 VPR Smile]
  3. Publish Encoded file over IIS
  4. Play the streamed media on Windows Phone 7 using smfPlayer.

Enable Smooth streaming on IIS

You need to download and install IIS Media Services. Go to below URL to download and install IIS Media Services.

http://www.iis.net/download/SmoothStreaming

image

After successful installation, you will have a section of Media Services in IIS.

image

 

Encode Media File

To encode media for IIS smooth streaming you need Microsoft Expression Encoder 4.0 pro. If you don’t have installed that then download and install that. It comes as part of Microsoft Expression.

Step 1

Very first open Microsoft Encoder Pro 4.0. You will get prompted to choose Project type to be loaded. Select Transcoding Project and press Ok.

image

Step 2

In this step you need to choose the media file to be encoded and streamed over IIS. Click on File in menu and select Import.

clip_image001

Choose media file to be encoded and streamed.

clip_image003

 

Step 3

In right side tab select Preset option. If you are unable to find Preset tab, select windows from menu and check preset.

clip_image004

From Preset tab select Encoding for Silverlight and then select IIS Smooth Streaming. After selecting option of IIS Smooth Streaming, you can choose VBR rate of your choice.

clip_image005

After IIS Smooth streaming type doesn’t forget to click Apply button.

Step 4

There are many options available for you to configure like,

  1. Thumbnails
  2. Security
  3. Template options
  4. Output path
  5. Publish etc

You can set values for above options as per your requirement. I am going to set output path here. Make sure you have created a folder on your local derive to set as output path for the encoded media for the streaming. On my local D drive, I have created a folder called StreamDemo. So set the output path as below

clip_image001[5]

Make sure to check Sub-folder by job ID. Leave Media File name as default name.

 

Step 5

If you have set the values for everything required then go ahead and click on the Encode button in the bottom.

clip_image002

You should be getting Encoding status message as below.

clip_image003

 

After successful encoding you will get encoded media playing the browser from the local derive. Now you have encoded media file.

 

Publish Encoded File over IIS

To stream over IIS, you need to publish encoded media over IIS. Process to publish encoded media is same as publishing any other web site over IIS.

Step 1

Open IIS as administrator and add a new web site

clip_image004[5]

Step 2

In dialog box you need to provide below information

  1. Site name: Give any name of your choice
  2. Port : Choose any available port above 1024
  3. Host Name : Leave it empty
  4. Type : Http
  5. Check the check box start web site immediately.
  6. In Physical path, give the same location Encoded file is saved. In previous step while encoding media for streaming, I save file in location D:\StreamDEmo. So I am going to set Physical Path as D:\StreamDEmo.

 

image

Click Ok to create web site in IIS. So we created site StreamingMediaDemo1. Right click on that and select Manage Web Site and then browse.

image

On browsing most likely you will get forbidden error message as below,

image

Append Default.html in URL to play the media.

clip_image001[7]

Media will be played as below,

image

 

Now append wildlife.ism/manifest to the URL. This manifest file would be used in Windows Phone 7 and other clients to stream media over IIS.

image

Playing in Windows Phone 7

To Play media on Windows Phone 7 download below player from the CodePlex.

http://smf.codeplex.com/releases/view/63434#DownloadId=222617

After download extract the file on locally. You will have to add references of these dll in Windows Phone project. Since dll got downloaded from the web, so they would be locked. To use them in the project right click and unblock them.

Note : I would recommend to download msi file and install that to get all the required files.

Step 1

Create a Windows Phone Application

clip_image002

Choose target Windows Phone version 7.0

clip_image003[5]

Step 2

Right click and add the references. If you have run msi then you will get below references at the location,

C:\Program Files (x86)\Microsoft SDKs\Microsoft Silverlight Media Framework\v2.4\Silverlight For Phone\Bin

clip_image005

Step 3

You need to download IIS smooth client and install from below URL.

http://www.iis.net/download/smoothclient

Step 4

Right click on Windows Phone 7 project and add reference of Microsoft.web.media.smoothstreaming.dll

To locate this file on your local drive browse to C:\Program Files (x86)\Microsoft SDKs\IIS Smooth Streaming Client\v1.5\Windows Phone on 64 bit machine.

clip_image007

 

Step 5

Next we need to design Silverlight page. Open MainPage.xaml and add namespace,

image

 

And add a player on the page downloaded to play stream media as below,

clip_image001[9]

Eventually xaml will be as below with a textblock to display message and player

Mainpage.xaml

 

<phone:PhoneApplicationPage
    x:Class="Streaming.MainPage"
    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:Core="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"
    xmlns:Media="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:ssme="clr-namespace:Microsoft.Web.Media.SmoothStreaming;assembly=Microsoft.Web.Media.SmoothStreaming"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="728" d:DesignHeight="480"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape"  Orientation="Landscape"
    shell:SystemTray.IsVisible="True">

    <!--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="page name" 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">
            <StackPanel Orientation="Vertical">
                <TextBlock Text="Streaming Media from IIS on Silverlight" Height="22" Width="266" FontSize="12" Foreground="Blue"/>
                <Core:SMFPlayer Name="strmPlayer"
                    HorizontalAlignment="Stretch"
                                 Margin="0"
                                 VerticalAlignment="Stretch"/>

            </StackPanel>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>

Step 6

We need to write some code on page load to create play list of streamed media and play in the player.

Mainpage.xaml .cs


using System;
using Microsoft.Phone.Controls;
using Microsoft.SilverlightMediaFramework.Core.Media;


namespace Streaming
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            PlaylistItem item = new PlaylistItem();
            item.MediaSource = new Uri("http://localhost:9173/wildlife.ism/manifest");
            item.DeliveryMethod = Microsoft.SilverlightMediaFramework.Plugins.Primitives.DeliveryMethods.AdaptiveStreaming;
            strmPlayer.Playlist.Add(item);
            strmPlayer.Play();

        }


    }
}

Step 7

Press F5 to run the application.

imageimage

These were what all required to smooth stream media from IIS and play in Windows Phone 7 client. I hope this post was useful. I am looking very forward for your comments on the post. Thanks for reading  Smile

 

Windows Phone SDK 7.1 Beta 2 released: installation steps

Note : Content of this post is taken as it is from release note of Windows Phone SDK 7.1 . Please read release document more carefully. I have listed the breaking relase opints as it is from there. Original content is on relase note.

On 27th June 2011 Windows Phone SDK 7.1 Beta 2 got released.

 

clip_image001

 

You can download it from below link,

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=26648

Release information is as below,

image

If you installed Windows Phone Developer Tools 7.1 Beta 1, you must uninstall it before installing Windows Phone SDK 7.1 Beta 2.

Few points ,

  1. There are many known issue in the release. So before installing read release document very carefully.
  2. There are many breaking changes like

 

  • Touch input for the ScrollViewer and ListBox controls happens on an independent thread by default, instead of on the UI thread.
  • Image decoding happens on a background thread by default, instead of on the UI thread.
  • The TaiwanCalendar class has been removed from the API.
  • The OnCancel override method was removed from the ScheduledTaskAgent class.
  • The IsRunningSlowly property was removed from the GameTimerEventArgs class.
  • IExecuteResult was removed from the Windows Phone OS 7.1 API.
  • The MotionReading property types have changed.
  • The Background Transfer Service folder in isolated storage was renamed.
  • Tile data in isolated storage must use the folder Shared\ShellContent.
  • The ShellTileEnumerator class was removed.
  • Background agents are not launched in the debugger by using the Add and Find methods.
  • The maximum and default database and buffer pool size values are now lower for SQLCE databases.
  • . Connection string parameters that are not supported are removed.
  • . Microsoft.Devices.YCrCbPixelLayout was renamed to Microsoft.Devices.YCbCrPixelLayout.
  • Microsoft.Devices.CaptureResolution was removed.

 

Installation of Winows Phone SDK 7.1 Beta 2

First uninstall Windows Phone SDK 7.1. Uninstall below items

  1. Windows Phone SDK 7.1 Beta
  2. Windows Phone Emulator (Beta)
  3. Microsoft Windows Phone Developer Tools 7.1

 

image

 

clip_image001

After uninstalling Beta 1 install Beta 2.

Screen shorts are as below Smile

clip_image002

 

clip_image003

 

 

clip_image004

 

 

clip_image005

 

clip_image006clip_image007

image

Enjoy with Windows Phone 7.1 Beta 2 Smile

 

 

 



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

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine