有很多關於如何使用背景音頻代理的例子,但很少展示如何使用背景音頻流媒體代理以及我發現的不顯示流媒體mp3,而是創建一個假裝流。如何在後臺通過HTTP流式傳輸MP3?
當我創建一個新的Windows Phone音頻流傳輸代理項目,它給了我:
public class AudioTrackStreamer : AudioStreamingAgent
{
/// <summary>
/// Called when a new track requires audio decoding
/// (typically because it is about to start playing)
/// </summary>
/// <param name="track">
/// The track that needs audio streaming
/// </param>
/// <param name="streamer">
/// The AudioStreamer object to which a MediaStreamSource should be
/// attached to commence playback
/// </param>
/// <remarks>
/// To invoke this method for a track set the Source parameter of the AudioTrack to null
/// before setting into the Track property of the BackgroundAudioPlayer instance
/// property set to true;
/// otherwise it is assumed that the system will perform all streaming
/// and decoding
/// </remarks>
protected override void OnBeginStreaming(AudioTrack track, AudioStreamer streamer)
{
//TODO: Set the SetSource property of streamer to a MSS source
NotifyComplete();
}
/// <summary>
/// Called when the agent request is getting cancelled
/// The call to base.OnCancel() is necessary to release the background streaming resources
/// </summary>
protected override void OnCancel()
{
base.OnCancel();
}
}
我怎麼給它一個MP3 URL像http://relay.radioreference.com:80/346246215,並在後臺流呢?我也可以放BackgroundAudioPlayer.Instance.Play();
來玩,就是這樣嗎?
如何設置網址?哪裏? – 2012-02-29 07:56:13
請參閱此鏈接http://msdn.microsoft.com/en-us/library/hh202978%28v=vs.92%29.aspx。在後臺音頻代理項目中,將AudioPlayer.cs文件中的音頻播放列表添加爲新的軌道。 (新Uri(「http://relay.radioreference.com:80/346246215」,UriKind.RelativeorAbsolute), 「AlbumName」, 「Artist」, 「Ninja Tuna」, Artpath); – Santhu 2012-02-29 08:30:52
謝謝。我會看看這是否會奏效。 – 2012-02-29 20:01:35