// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// Gets the effective thumbnail for this item. This goes down tree /// </summary> /// <returns>RssMediaThumbnail</returns> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public RssMediaThumbnail GetThumbnailAll() { RssMediaThumbnail rt = rssUtil.GetThumbnail(this); if (rt == null) { for (int i = 0; i < mediaContentItems.Count; i++) { rt = rssUtil.GetThumbnail(mediaContentItems[i]); if (rt != null) { break; } } } if (rt == null) { for (int i = 0; i < mediaGroups.Count; i++) { rt = rssUtil.GetThumbnail(mediaGroups[i]); if (rt != null) { break; } } } return(rt); }
// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// Gets the media thumbnails for an item /// </summary> /// <param name="obj">IRssMediaExtension</param> /// <returns>RssMediaThumbnail</returns> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public RssMediaThumbnail GetThumbnail(IRssMediaExtension obj) { RssMediaThumbnail rt = null; IEnumerable<RssMediaThumbnail> lst = GetThumbnails(obj); if (lst.Count() > 0) { rt = lst.First(); } return rt; }
// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// Helper method to add media thumbnail /// </summary> /// <param name="url">image url</param> /// <param name="width">width</param> /// <param name="height">height</param> /// <param name="startTimeInTicks">Start time thumbnail should be displayed</param> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public void AddMediaThumbnail(string url, int width = 0, int height = 0, long startTimeInTicks = 0) { RssMediaThumbnail obj = new RssMediaThumbnail(); obj.url = url; obj.width = width; obj.height = height; if (startTimeInTicks > 0) { obj.time = new TimeSpan(startTimeInTicks); } MediaThumbnails.Add(obj); }
// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// Gets the effective media thumbnail for the media extension object. /// In this case, it simply returns the first one found /// </summary> /// <returns>RssMediaThumbnail</returns> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public RssMediaThumbnail GetFirstThumbnail() { RssMediaThumbnail rt = null; for (int i = 0; i < MediaThumbnails.Count; i++) { if (MediaThumbnails[i].url.Length > 0) { rt = MediaThumbnails[i]; break; } } return(rt); }
// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// Gets the effective thumbnail for this item. This searches children /// </summary> /// <returns>RssMediaThumbnail</returns> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public RssMediaThumbnail GetThumbnailAll() { RssMediaThumbnail rt = rssUtil.GetThumbnail(this); if (rt == null) { for (int i = 0; i < items.Count; i++) { rt = items[i].GetThumbnailAll(); if (rt != null) { break; } } } return(rt); }
// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// Adds a media thumbnail object /// </summary> /// <param name="obj"></param> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public void AddMediaThumbnail(RssMediaThumbnail obj) { mediaOptions.AddMediaThumbnail(obj); }
// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// Adds a media thumbnail object /// </summary> /// <param name="obj">RssMediaThumbnail object</param> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public void AddMediaThumbnail(RssMediaThumbnail obj) { MediaThumbnails.Add(obj); }
// ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- /// <summary> /// This loads property of the RssMediaExtension object with the contents of the /// XElement /// </summary> /// <param name="el">Parent XElement</param> // ------------------------------------------------------------------------------- // ------------------------------------------------------------------------------- public void LoadEl(XElement el) { // process this switch only if element is in the media namespace if (el.Name.Namespace == RSS.MEDIA_NS) { switch (el.Name.LocalName) { case RssMediaRating.TAG_PARENT: RssMediaRating rating = new RssMediaRating(); rating.Load(el); MediaRatings.Add(rating); break; case RssMediaTitle.TAG_PARENT: MediaTitle = new RssMediaTitle(); MediaTitle.Load(el); break; case RssMediaDescription.TAG_PARENT: MediaDescription = new RssMediaDescription(); MediaDescription.Load(el); break; case RssMediaKeywords.TAG_PARENT: MediaKeywords = new RssMediaKeywords(); MediaKeywords.Load(el); break; case RssMediaThumbnail.TAG_PARENT: RssMediaThumbnail thumb = new RssMediaThumbnail(this); thumb.Load(el); MediaThumbnails.Add(thumb); break; case RssMediaCategory.TAG_PARENT: RssMediaCategory MediaCategory = new RssMediaCategory(); MediaCategory.Load(el); MediaCategories.Add(MediaCategory); break; case RssMediaHash.TAG_PARENT: RssMediaHash hash = new RssMediaHash(); hash.Load(el); MediaHashes.Add(hash); break; case RssMediaPlayer.TAG_PARENT: MediaPlayer = new RssMediaPlayer(); MediaPlayer.Load(el); break; case RssMediaCredit.TAG_PARENT: RssMediaCredit credit = new RssMediaCredit(); credit.Load(el); MediaCredits.Add(credit); break; case RssMediaCopyright.TAG_PARENT: MediaCopyright = new RssMediaCopyright(); MediaCopyright.Load(el); break; case RssMediaText.TAG_PARENT: RssMediaText txt = new RssMediaText(); txt.Load(el); MediaTexts.Add(txt); break; case RssMediaRestriction.TAG_PARENT: RssMediaRestriction restriction = new RssMediaRestriction(); restriction.Load(el); MediaRestrictions.Add(restriction); break; case RssMediaCommunity.TAG_PARENT: MediaCommunity = new RssMediaCommunity(); MediaCommunity.Load(el); break; case RssMediaComments.TAG_PARENT: MediaComments = new RssMediaComments(); MediaComments.Load(el); break; case RssMediaEmbed.TAG_PARENT: MediaEmbed = new RssMediaEmbed(); MediaEmbed.Load(el); break; case RssMediaResponses.TAG_PARENT: MediaResponses = new RssMediaResponses(); MediaResponses.Load(el); break; case RssMediaBacklinks.TAG_PARENT: MediaBacklinks = new RssMediaBacklinks(); MediaBacklinks.Load(el); break; case RssMediaStatus.TAG_PARENT: MediaStatus = new RssMediaStatus(); MediaStatus.Load(el); break; case RssMediaPrice.TAG_PARENT: RssMediaPrice price = new RssMediaPrice(); price.Load(el); MediaPrices.Add(price); break; case RssMediaLicense.TAG_PARENT: MediaLicense = new RssMediaLicense(); MediaLicense.Load(el); break; case RssMediaSubtitle.TAG_PARENT: RssMediaSubtitle subtitle = new RssMediaSubtitle(); subtitle.Load(el); MediaSubtitles.Add(subtitle); break; case RssMediaPeerLink.TAG_PARENT: MediaPeerLink = new RssMediaPeerLink(); MediaPeerLink.Load(el); break; case RssMediaRights.TAG_PARENT: MediaRights = new RssMediaRights(); MediaRights.Load(el); break; case RssMediaScenes.TAG_PARENT: MediaScenes = new RssMediaScenes(); MediaScenes.Load(el); break; case RssMediaLocation.TAG_PARENT: RssMediaLocation mediaLocation = new RssMediaLocation(); mediaLocation.Load(el); MediaLocations.Add(mediaLocation); break; } } // Dublin core terms namespace else if (el.Name.Namespace == RSS.DUBLIN_CORE_TERMS_NS) { switch (el.Name.LocalName) { case RssDublinCoreValid.TAG_PARENT: MediaValid = new RssDublinCoreValid(); MediaValid.Load(el); break; } } else if (el.Name.Namespace == RSS.GEORSS_NS) { } else if (el.Name.Namespace == RSS.GML_NS) { } }