Есть много примеров того, как использовать фоновый аудио агент, но очень мало показывают, как использовать фоновый аудиопоток и те, которые я нашел, не показывают потокового mp3, а вместо этого создают притворный поток.Как я могу передать MP3 через HTTP в фоновом режиме?
Когда я создаю новый проект Windows Phone Audio Streaming Агент, это дает мне:
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();
, чтобы воспроизвести его и все?
Как установить URL-адрес? Где? –
См. Эту ссылку http://msdn.microsoft.com/en-us/library/hh202978%28v=vs.92%29.aspx. В проекте «Фоновый аудио агент» в аудио-плейлисте AudioPlayer.cs добавьте новый трек. как указано ниже, новый AudioTrack (новый Uri («http://relay.radioreference.com:80/346246215», UriKind.RelativeorAbsolute), «AlbumName», «Исполнитель», «Ninja Tuna», Artpath); – Santhu
Спасибо. Я посмотрю, будет ли это работать. –