有很多关于如何使用背景音频代理的例子,但很少展示如何使用背景音频流媒体代理以及我发现的不显示流媒体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