2011-08-10 6 views
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); 
    } 
} 

정말 설명이 필요한 마지막 방법입니다. 왜 나쁜 생각인지, 어떻게 다르게 처리해야하는지에 대한 통지를 이해할 수 없습니까?

+0

어떻게하는지 알아 냈습니까? –

답변

0

기본적으로 재생되기 전에 파일 1 개를 완전히 다운로드 중임을 알려줍니다. 파일이 10MB이면 완전히 다운로드되기까지 시간이 걸릴 수 있으므로 좋은 생각은 아닙니다.

더 좋은 아이디어는 인코더를 사용하여 파일을 청크하고 필요에 따라 읽는 것입니다.