internal static PlayRange Merge(this IMediaSource mediaSource, PlayRange first, PlayRange second) { if (!mediaSource.CanMerge(first, second)) { throw new InvalidOperationException(); } first = mediaSource.Adjust(first); second = mediaSource.Adjust(second); if (mediaSource.HasNativeDuration()) { return(PlayRange.Merge(first, second)); } else { return(new PlayRange(first.Duration + second.Duration)); } }
internal NormalPlaySource(IMediaSource mediaSource, PlayRange range) { if (mediaSource == null) { throw new ArgumentNullException("mediaSource"); } range = mediaSource.Adjust(range); this.MediaSource = mediaSource; this.PlayRange = range; }
//public TimeSpan? NativeDuration //{ // get // { // return this.MediaSource.NativeDuration; // } //} public MarkableMediaSource(IMediaSource mediaSource, PlayRange playRange) { if (mediaSource == null) { throw new ArgumentNullException("mediaSource"); } var adjustedPlayRange = mediaSource.Adjust(playRange); // 包含对playRange有效性的验证 //MarkableMediaSource markable = mediaSource as MarkableMediaSource; //if (markable!=null) //{ // this.MediaSource = markable.MediaSource; //} //else //{ // this.MediaSource = mediaSource; //} this.MediaSource = mediaSource; this.PlayRange = adjustedPlayRange; }
internal static bool CanMerge(this IMediaSource mediaSource, PlayRange first, PlayRange second) { return(mediaSource.HasNativeDuration() ? PlayRange.IsUnbroken(mediaSource.Adjust(first), mediaSource.Adjust(second)) : true); }