WP7播放Smooth Streaming
首先Smooth Streaming是啥?
参见介绍:
- http://www.microsoft.com/silverlight/smoothstreaming/
- http://www.iis.net/download/SmoothStreaming
- http://learn.iis.net/page.aspx/626/smooth-streaming-technical-overview/
1,安装IIS Media Services
要IIS支持Live Smooth,需要安装IIS Media Services
安装方式有两种:
- Web Platform Installer
- 直接下载安装包(MSI)
1.1,Web Platform Installer:http://www.iis.net/media
1.2,直接下载:
X86:http://www.microsoft.com/en-us/download/details.aspx?id=27956
X64:http://www.microsoft.com/en-us/download/details.aspx?id=27955
安装后在IIS里就能看到了
2,Expression Encoder 编码
随便找个小视频大概演示下吧,大视频一是速度慢,二是占硬盘…
编码完生成文件:
3,部署到IIS服务器上
吧文件拷贝到服务器,由于我们不是实时视频流,所以要看 Smooth Streaming Presentations里面
可以看到已经有我们编码过的视频了
4,WP7手机访问
WP默认不支持live smooth,因此需要第三方播放组件:http://smf.codeplex.com/
另外我们还需要Smooth Streaming Client:http://www.iis.net/download/smoothclient
我们新建一个wp工程(7.1,7.0不支持额)
然后添加引用:
添加完成后:
然后在页面添加:
xmlns:Core="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"
xmlns:Media="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"
xmlns:Media="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"
然后添加播放器和播放列表:
<Core:SMFPlayer AutoPlay="False" Name="strmPlayer">
<Core:SMFPlayer.Playlist>
<Media:PlaylistItem DeliveryMethod="AdaptiveStreaming" MediaSource="http://192.168.0.1/livesmooth/infotec office.ism/manifest"/>
</Core:SMFPlayer.Playlist>
</Core:SMFPlayer>
<Core:SMFPlayer.Playlist>
<Media:PlaylistItem DeliveryMethod="AdaptiveStreaming" MediaSource="http://192.168.0.1/livesmooth/infotec office.ism/manifest"/>
</Core:SMFPlayer.Playlist>
</Core:SMFPlayer>
然后我们就能在手机中观看视频了:
当然,我们也可以通过code来播放
1 private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
2 {
3 strmPlayer.Playlist.Clear();
4 PlaylistItem item = new PlaylistItem();
5 item.MediaSource = new Uri("http://192.168.0.1/livesmooth/infotec office.ism/manifest");
6 item.DeliveryMethod = DeliveryMethods.AdaptiveStreaming;
7 strmPlayer.Playlist.Add(item);
8 strmPlayer.Play();
9 }
2 {
3 strmPlayer.Playlist.Clear();
4 PlaylistItem item = new PlaylistItem();
5 item.MediaSource = new Uri("http://192.168.0.1/livesmooth/infotec office.ism/manifest");
6 item.DeliveryMethod = DeliveryMethods.AdaptiveStreaming;
7 strmPlayer.Playlist.Add(item);
8 strmPlayer.Play();
9 }
参考:
- http://smf.codeplex.com/documentation
- http://blogs.msdn.com/b/giuseppeguerrasio/archive/2010/12/06/using-smooth-streaming-media-element-for-windows-phone-7.aspx
源码:
作者:sun8134
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。