public MarkableMediaSource(IMediaSource mediaSource)
        {
            if (mediaSource == null)
            {
                throw new ArgumentNullException("mediaSource");
            }

            this.PlayRange   = mediaSource.GetNativePlayRange();
            this.MediaSource = mediaSource;
        }
 private static bool IsValidPlayRange(this IMediaSource mediaSource, PlayRange playRange)
 {
     if (mediaSource.HasNativeDuration())
     {
         return(mediaSource.GetNativePlayRange().Include(playRange));
     }
     else
     {
         return(playRange.StartPosition == TimeSpan.Zero);
     }
 }
 private static void ValidatePlayRange(this IMediaSource mediaSource, PlayRange playRange)
 {
     if (!mediaSource.IsValidPlayRange(playRange))
     {
         if (mediaSource.HasNativeDuration())
         {
             throw new ArgumentException(
                       string.Format("{0}无效,有效范围为:{1}。", playRange, mediaSource.GetNativePlayRange()),
                       "playRange");
         }
         else
         {
             throw new ArgumentException(
                       string.Format("{0}无效,起始位置必须为TimeSpan.Zero。", playRange),
                       "playRange");
         }
     }
 }