2011-07-22 48 views
5

當我把我的SmoothStreamingSource,然後調用.Play()我得到下面的異常...SmoothStreamingMediaElement.Play() - 拋出異常,但玩家開始

「玩的不是時候沒有源組所允許。 「

奇怪的是,如果我處理這個異常(如下面的代碼所示),視頻確實開始播放。奇?根據msdn,SmoothStreamingSource屬性自動設置Source屬性,所以我不應該得到一個異常。逐句通過代碼確認Source屬性在設置SmoothStreamingSource屬性後設置。

我寧願不只是處理異常,如果這是內部更大的問題的標誌,繼續我的快樂方式。

這是怎麼回事?我的代碼...

try 
     { 
      Uri uri = (Uri)((Button)source).Tag; 

      smoothStreamingMediaElement1.SmoothStreamingSource = uri; 

      if (smoothStreamingMediaElement1.SmoothStreamingSource != null) 
       MessageBox.Show(smoothStreamingMediaElement1.SmoothStreamingSource.ToString()); 
      else 
       MessageBox.Show("SmoothStreamingSource is NULL"); 

      smoothStreamingMediaElement1.Play(); 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.Message); 
     } 
+0

我從1.1到1.5平滑的客戶端後,我有同樣的問題...似乎沒有人使用這些功能... –

回答

4

當您設置SmoothStreamingSource屬性時,您只需設置一個Uri變量即可。

爲了讓玩家開始遊戲,您需要等待SmoothStreamingMediaElement下載包含播放流所需的所有信息的清單。

因此,在您設置SmoothStreamingSource屬性後,我不會馬上調用Play方法,而是訂閱ManifestReady或MediaOpened事件,然後才調用Play方法。

+0

謝謝,這真的幫助我! –