0
我想在我的Windows Phone應用程序中播放shoutcast音頻。我有我從一些網站得到的以下代碼。通過URL的BackgroundAudioPlayer
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);
}
}
}
}
}
}
現在,事情是,這個例子播放一個內部文件。而且由於我是新手入門,所以我不明白爲了給這個玩家一個播放網址應該遵循什麼規定。請幫助通過URL在BackgroundAudioPlayer中播放音頻。任何形式的幫助表示讚賞,因爲我急需這一點。感謝所有提前..
您是否已經創建了背景[AudioAgent](http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394039(v = vs.105).aspx)? –
不,我可以稍微解釋一下,因爲這些讓我感到困惑。 – Akshat