2011-07-22 38 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

谢谢,这真的帮助我! –