How to play a streamed mp3 on Windows Phone 7
Article Metadata
Tested with
SDK: Windows Phone 7.1
Devices(s): Nokia Lumia 800
Compatibility
Platform(s): Windows Phone 7.5
Article
Created: sreerajvr
(06 Apr 2012)
Last edited: hamishwillee
(30 Nov 2012)
Introduction
How To
- To start creating a new Windows Phone Application, start Microsoft Visual studio then create a new Project and select Windows Phone Application Template
- In Visual Studio Solution Explorer, right-click References under your project and click Add Reference
- In the Add Reference dialog box, click the .NET tab. Click 'Microsoft.Xna.Framework' entry to select it, and click OK.
- In the Solution Explorer panel, you will see the 'Microsoft.Xna.Framework' listed in the References folder of your project.
- In the source file that you want to use to program on XNA MediaPlayer classes, add the following code in the using section of your code.
using Microsoft.Xna.Framework.Media;
code
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;
using Microsoft.Xna.Framework.Media;//for getting MediaPlayer
namespace MP3Playback
{
public partial class MainPage : PhoneApplicationPage
{
string url = "http://traffic.libsyn.com/slashfilmcast/Davidmichod.mp3";//your url link
// Constructor
public MainPage()
{
InitializeComponent();
Microsoft.Xna.Framework.FrameworkDispatcher.Update();
Song track = Song.FromUri("Sample Song", new Uri(url));
MediaPlayer.Play(track);
}
}
}


Chintandave er - Complete article please.
Hi sreerajvr,
This article seems uncompleted. Introduction is not yet completed. So Please complete it. It would be also good if you add some image of this demo app.
Thanks,
Chintan.Chintandave er 23:23, 13 April 2012 (EEST)
Hamishwillee - Agree with Chintan
Hi sreerajvr
If you create an article that is obviously incomplete, its hard for users to know whether they should rely on it or not.
IN addition, it would really help if you provided links to the reference material you used to create this, and explain how the code is used and where/when you would use it. Ie is this for pure XNA code, or for mixing with silverlight?
Regards
Hamishhamishwillee 09:10, 1 May 2012 (EEST)