我想在我的 Windows Phone 应用程序中播放广播音频。我有以下从某个网站获得的代码。
namespace WPBackgroundAudioDemo
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
SaveToIsoStore();
}
private void buttonStart_Click(object sender, RoutedEventArgs e)
{
if (BackgroundAudioPlayer.Instance.PlayerState != PlayState.Playing )
BackgroundAudioPlayer.Instance.Play();
}
private void buttonStop_Click(object sender, RoutedEventArgs e)
{
if (BackgroundAudioPlayer.Instance.PlayerState != PlayState.Stopped)
BackgroundAudioPlayer.Instance.Stop();
}
private void SaveToIsoStore()
{
IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!isolatedStorageFile.FileExists("Lullabies.mp3"))
{
StreamResourceInfo resource = Application.GetResourceStream(new Uri("Lullabies.mp3", UriKind.Relative));
using (IsolatedStorageFileStream isolatedStorageFileStream = isolatedStorageFile.CreateFile("Lullabies.mp3"))
{
int chunkSize = 1024;
byte[] bytes = new byte[chunkSize];
int byteCount;
while ((byteCount = resource.Stream.Read(bytes, 0, chunkSize)) > 0)
{
isolatedStorageFileStream.Write(bytes, 0, byteCount);
}
}
}
}
}
}
现在,问题是这个例子播放的是一个内部文件。而且由于我是 Windows 新手,我不明白应该遵循什么来给这个播放器一个直播网址。请帮助通过 URL 在 BackgroundAudioPlayer 中播放音频。任何形式的帮助表示赞赏,因为我迫切需要这个。提前谢谢大家..