WP7播放Smooth Streaming

首先Smooth Streaming是啥?

参见介绍:

1,安装IIS Media Services

要IIS支持Live Smooth,需要安装IIS Media Services

安装方式有两种:

  • Web Platform Installer
  • 直接下载安装包(MSI)

1.1,Web Platform Installer:http://www.iis.net/media

image

image

image

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里就能看到了

image

2,Expression Encoder 编码

随便找个小视频大概演示下吧,大视频一是速度慢,二是占硬盘…

image

image

image 

编码完生成文件:

image

3,部署到IIS服务器上

吧文件拷贝到服务器,由于我们不是实时视频流,所以要看 Smooth Streaming Presentations里面

image

可以看到已经有我们编码过的视频了

image

4,WP7手机访问

WP默认不支持live smooth,因此需要第三方播放组件:http://smf.codeplex.com/

另外我们还需要Smooth Streaming Client:http://www.iis.net/download/smoothclient

我们新建一个wp工程(7.1,7.0不支持额)

image

然后添加引用:

image

添加完成后:

image

然后在页面添加:

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" 

然后添加播放器和播放列表:

            <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>

然后我们就能在手机中观看视频了:

image

当然,我们也可以通过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         }

参考:

源码:

原文地址:https://www.cnblogs.com/sun8134/p/2499296.html