本文整理汇总了C++中TimeRanges::intersectWith方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeRanges::intersectWith方法的具体用法?C++ TimeRanges::intersectWith怎么用?C++ TimeRanges::intersectWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeRanges
的用法示例。
在下文中一共展示了TimeRanges::intersectWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buffered
TimeRanges* MediaSource::buffered() const {
// Implements MediaSource algorithm for HTMLMediaElement.buffered.
// https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#htmlmediaelement-extensions
HeapVector<Member<TimeRanges>> ranges(m_activeSourceBuffers->length());
for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i)
ranges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXCEPTION);
// 1. If activeSourceBuffers.length equals 0 then return an empty TimeRanges
// object and abort these steps.
if (ranges.isEmpty())
return TimeRanges::create();
// 2. Let active ranges be the ranges returned by buffered for each
// SourceBuffer object in activeSourceBuffers.
// 3. Let highest end time be the largest range end time in the active ranges.
double highestEndTime = -1;
for (size_t i = 0; i < ranges.size(); ++i) {
unsigned length = ranges[i]->length();
if (length)
highestEndTime = std::max(
highestEndTime, ranges[i]->end(length - 1, ASSERT_NO_EXCEPTION));
}
// Return an empty range if all ranges are empty.
if (highestEndTime < 0)
return TimeRanges::create();
// 4. Let intersection ranges equal a TimeRange object containing a single
// range from 0 to highest end time.
TimeRanges* intersectionRanges = TimeRanges::create(0, highestEndTime);
// 5. For each SourceBuffer object in activeSourceBuffers run the following
// steps:
bool ended = readyState() == endedKeyword();
for (size_t i = 0; i < ranges.size(); ++i) {
// 5.1 Let source ranges equal the ranges returned by the buffered attribute
// on the current SourceBuffer.
TimeRanges* sourceRanges = ranges[i].get();
// 5.2 If readyState is "ended", then set the end time on the last range in
// source ranges to highest end time.
if (ended && sourceRanges->length())
sourceRanges->add(
sourceRanges->start(sourceRanges->length() - 1, ASSERT_NO_EXCEPTION),
highestEndTime);
// 5.3 Let new intersection ranges equal the the intersection between the
// intersection ranges and the source ranges.
// 5.4 Replace the ranges in intersection ranges with the new intersection
// ranges.
intersectionRanges->intersectWith(sourceRanges);
}
return intersectionRanges;
}