从Silverlight Media Player Framework获取视频高度

时间:2011-10-03 19:09:23

标签: silverlight windows-phone-7

我使用Smf.CodePlex.com框架。如何从渐进式下载流(Windows Phone)获取实际视频大小

我试过了:

    var item = TvPlayer.CurrentPlaylistItem;                        
    var videoHeight = item.VideoHeight;             
    var videoWidth = item.VideoWidth;

以及

    var videoHeight = TvPlayer.VideoHeight;             
    var videoWidth = TvPlayer.VideoWidth; 

两者都归还NaN。任何线索?

2 个答案:

答案 0 :(得分:1)

我找到了。您必须获得渐进式下载插件的引用(通过事件处理程序)

    void TvPlayer_MediaPluginRegistered(object sender, CustomEventArgs<Microsoft.SilverlightMediaFramework.Plugins.IMediaPlugin> e)
    {
        IMediaPlugin a = e.Value;
        if (a.GetType() == typeof(ProgressiveMediaPlugin))
            _progressivePlugin = e.Value;
    }

在插件上找到了NaturalVideoSize .....

        var videoHeight = _progressivePlugin.NaturalVideoSize.Height;
        var videoWidth = _progressivePlugin.NaturalVideoSize.Width;

答案 1 :(得分:0)

我对这个框架知之甚少,但我确实发现了这个:

SMF v2 "How To" Documentation

希望这有帮助! :)