Namespaces
Variants
Actions

How to play a streamed mp3 on Windows Phone 7

Jump to: navigation, search
WP Metro Icon XNA.png
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

  1. To start creating a new Windows Phone Application, start Microsoft Visual studio then create a new Project and select Windows Phone Application Template
  2. In Visual Studio Solution Explorer, right-click References under your project and click Add Reference
  3. In the Add Reference dialog box, click the .NET tab. Click 'Microsoft.Xna.Framework' entry to select it, and click OK.
  4. In the Solution Explorer panel, you will see the 'Microsoft.Xna.Framework' listed in the References folder of your project.
  5. 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);
 
}
}
}
This page was last modified on 30 November 2012, at 08:16.
173 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved