2012-03-07 166 views
-1

嘗試使用BackgroundAudioAgent就像以前的文章: How do I stream an MP3 over HTTP in the background?WP7 HTTP流媒體音頻

回答說乾脆把radioreference.relay.com URL在AudioTrack對象。

這裏是我的代碼:

 // A playlist made up of AudioTrack items. 
    private static List<AudioTrack> _playList = new List<AudioTrack> 
    { 
     new AudioTrack(new Uri("Ring01.wma", UriKind.Relative), 
         "Ringtone 1", 
         "Windows Phone", 
         "Windows Phone Ringtones", 
         //new Uri("shared/media/Ring01.jpg", UriKind.Relative)), 
         null), 

     // A remote URI 
     new AudioTrack(new Uri("http://relay.radioreference.com:80/346246215", UriKind.RelativeOrAbsolute), 
          "Title", 
          "Artist", 
          "Album", 
          null), 


     // A remote URI 
     new AudioTrack(new Uri("http://traffic.libsyn.com/wpradio/WPRadio_29.mp3", UriKind.Absolute), 
         "Episode 29", 
         "Windows Phone Radio", 
         "Windows Phone Radio Podcast", 
         //new Uri("shared/media/Episode29.jpg", UriKind.Relative)) 
         null) 
    }; 

從那裏,它只是微軟的示例代碼(http://go.microsoft.com/fwlink/?LinkId=226292)。

來自示例播放的第一條和第三條曲目,但radioreference.com曲目不起作用。我嘗試刪除:80,將UriKind更改爲Absolute,刪除http等。它調用示例代碼中的OnError處理函數,然後退出。

有關於此的任何其他想法?

+0

[請檢查這個問題,我的答案,它可以幫助你。] [1] [1]:http://stackoverflow.com/questions/9490356/how-do-i-stream -an-mp3-over-the-the-the-background/9493506#9493506 – Santhu 2012-03-07 06:25:26

+0

這就是我所指的,但它不適用於我。你有代碼,實際與我的代碼中列出的URL一起工作嗎?我知道這是有效的,因爲我可以用MediaElement播放它沒問題。 – 2012-03-07 06:30:43

+0

你是否可以用任何其他流媒體播放器播放與WMP或媒體元素相同的網址文件? – Santhu 2012-03-07 07:23:59

回答

0

好吧,顯然是爲relay.radioreference.com我實際上只需要添加.mp3擴展名,即使MediaElement不需要它。

  new AudioTrack(new Uri("http://relay.radioreference.com/346246215.mp3", UriKind.RelativeOrAbsolute), 
          "Title 3", 
          "Artist", 
          "Album", 
          null), 

Duh。希望這可以幫助其他使用relay.radioreference.com的人。