1
그래서 http://archive.msdn.microsoft.com/ManagedMediaHelpers에서 샘플을 다운로드했습니다.WP7 오디오 스트리밍 도움말
나는 MP3MediaStreamSource를 사용하여 코드 작업을하고 있습니다. 그러나, 나는 코드가 어떤 설명을 원한다는 것을 충분히 이해하지 못한다.
public partial class MainPage : PhoneApplicationPage
{
private static string mediaFileLocation = "http://file-here.mp3";
private static HttpWebRequest request = null;
private static Mp3MediaStreamSource mss = null;
public MainPage()
{
InitializeComponent();
}
private void RequestCallback(IAsyncResult asyncResult)
{
HttpWebResponse response = request.EndGetResponse(asyncResult) as HttpWebResponse;
Stream s = response.GetResponseStream();
mss = new Mp3MediaStreamSource(s, response.ContentLength);
Deployment.Current.Dispatcher.BeginInvoke(
() =>
{
this.wp7AudioElement.Volume = 100;
this.wp7AudioElement.SetSource(mss);
});
}
private void Button_Click(object sender, RoutedEventArgs e)
{
request = WebRequest.CreateHttp(MainPage.mediaFileLocation);
// NOTICE
// Makes this demo code easier but I wouldn't do this on a live phone as it will cause the whole
// file to download into memory at once.
//
// Instead, use the asynchronous methods and read the stream in the backgound and dispatch its
// data as needed to the ReportGetSampleCompleted call on the UIThread.
request.AllowReadStreamBuffering = true;
IAsyncResult result = request.BeginGetResponse(new AsyncCallback(this.RequestCallback), null);
}
}
정말 설명이 필요한 마지막 방법입니다. 왜 나쁜 생각인지, 어떻게 다르게 처리해야하는지에 대한 통지를 이해할 수 없습니까?
어떻게하는지 알아 냈습니까? –