如何从sitecore媒体项检索视频详细信息?

时间:2016-01-18 09:19:52

标签: c# sitecore

我在网站上实施视频站点地图,我正在尝试在sitecore中获取视频的详细信息。我可以阅读标题,描述等细节。但是如何获得以下详细信息,如持续时间,播放器位置和下面提到的XML中的其他详细信息

<video:video>
       <video:thumbnail_loc>http://www.example.com/thumbs/123.jpg</video:thumbnail_loc> 
       <video:title>Grilling steaks for summer</video:title>
       <video:description>Alkis shows you how to get perfectly done steaks every            
         time</video:description>
       <video:content_loc>http://www.example.com/video123.flv</video:content_loc>
       <video:player_loc allow_embed="yes" autoplay="ap=1">
         http://www.example.com/videoplayer.swf?video=123</video:player_loc>
       <video:duration>600</video:duration>
       <video:expiration_date>2009-11-05T19:20:30+08:00</video:expiration_date>
       <video:rating>4.2</video:rating> 
       <video:view_count>12345</video:view_count>    
       <video:publication_date>2007-11-05T19:20:30+08:00</video:publication_date>
       <video:family_friendly>yes</video:family_friendly>   
       <video:restriction relationship="allow">IE GB US CA</video:restriction> 
       <video:gallery_loc title="Cooking Videos">http://cooking.example.com</video:gallery_loc>
       <video:price currency="EUR">1.99</video:price>
       <video:requires_subscription>yes</video:requires_subscription>
       <video:uploader info="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson
         </video:uploader>
       <video:live>no</video:live>
     </video:video> 

这是我的代码:

HtmlAgilityPack.HtmlDocument document = htmlWeb.Load("http://www.example.com/us/cars/new-models/xc60");
var urls = document.DocumentNode.Descendants("source")
           .Select(x => x.Attributes[1].Value).ToList();
DynamicLink dynamicLink;
_videoval = new Videodetails();
foreach (var singleurl in urls)
    {
      if (!DynamicLink.TryParse(singleurl, out dynamicLink))
      return;
      MediaItem mediaItem = Sitecore.Context.Database.GetItem(dynamicLink.ItemId, dynamicLink.Language ?? Sitecore.Context.Language);
      var videodetail = new Videodetails() { Title = mediaItem.Title,Description = mediaItem.Description };
      videolist.Add(videodetail);
    }

1 个答案:

答案 0 :(得分:0)

Sitecore不会读取或存储有关媒体库中视频文件的元数据。因此,您需要从媒体项中检索附加的视频文件,并自己阅读元数据。

我发现了一篇关于阅读视频文件http://www.levibotelho.com/development/get-the-length-of-a-video-in-c/的持续时间的相当简单和体面的博文,我相信你可以找到某种.NET库来提取你需要的任何其他数据。

干杯,博