Windows Phone 7 - Playing streaming video

爷,独闯天下 提交于 2020-01-04 06:13:10

问题


On WP7 platform (using C# and Silverlight) I try to play an online stream into a MediaElement...

Here is the C# code: (...)

WebClient wc = new WebClient();                
wc.OpenReadCompleted += (s, e) =>
  {
   try
   {
     mediaElement.SetSource(e.Result);
   }
   catch (Exception we)
   {
     System.Diagnostics.Debug.WriteLine(we.Message);
   }
  };
wc.OpenReadAsync(new Uri(url, UriKind.Absolute));

(...) Here is the XAML source code:

<MediaElement Height="316" HorizontalAlignment="Left" Margin="6,6,0,0" Name="mediaElement" VerticalAlignment="Top" Width="450" AutoPlay="False" />

The url is type of http://.../Manifest and the format is a one supported by the platform.

When SetSource is called then an exception is raised with the following message "Stream must be of type IsolatedStorageFileStream".

What do I do wrong?

Thanks in advance for some help Cheers


回答1:


MSDN says:

Passing a generic stream to SetSource(System.IO.Stream) is not supported in Silverlight for Windows Phone. However, the IsolatedStorageFileStream class, which derives from Stream, is suppoted on Silverlight for Windows Phone.

Instead, consider setting the MediaElement.Source property directly to the stream uri. There's no reason to "download" it first.



来源:https://stackoverflow.com/questions/7511851/windows-phone-7-playing-streaming-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!