gpt4 book ai didi

c# - 如何在后台通过 HTTP 流式传输 MP3?

转载 作者:太空狗 更新时间:2023-10-30 00:05:41 25 4
gpt4 key购买 nike

有很多关于如何使用后台音频代理的示例,但很少有展示如何使用后台音频流代理的示例,我发现的示例不显示流式 mp3,而是创建假装流。

当我创建一个新的 Windows Phone Audio Streaming Agent 项目时,它会给我:

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();
}
}

我如何给它一个像 http://relay.radioreference.com:80/346246215 这样的 MP3 URL让它在后台流式传输?我是否也放了 BackgroundAudioPlayer.Instance.Play(); 来播放它,仅此而已?

最佳答案

是的,这就够了 不需要流媒体,如果您将URL设置为后台代理并调用函数BackgroundAudioPlayer.Instance.Play();后台代理自动流媒体

关于c# - 如何在后台通过 HTTP 流式传输 MP3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9490356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com