本文整理汇总了C++中TextTrackCue::EndTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TextTrackCue::EndTime方法的具体用法?C++ TextTrackCue::EndTime怎么用?C++ TextTrackCue::EndTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextTrackCue
的用法示例。
在下文中一共展示了TextTrackCue::EndTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TextTrackCueList*
TextTrack::GetActiveCues()
{
if (mMode == TextTrackMode::Disabled || !mMediaElement) {
return nullptr;
}
// If we are dirty, i.e. an event happened that may cause the sorted mCueList
// to have changed like a seek or an insert for a cue, than we need to rebuild
// the active cue list from scratch.
if (mDirty) {
mCuePos = 0;
mDirty = true;
mActiveCueList->RemoveAll();
}
double playbackTime = mMediaElement->CurrentTime();
// Remove all the cues from the active cue list whose end times now occur
// earlier then the current playback time. When we reach a cue whose end time
// is valid we can safely stop iterating as the list is sorted.
for (uint32_t i = 0; i < mActiveCueList->Length() &&
(*mActiveCueList)[i]->EndTime() < playbackTime; i++) {
mActiveCueList->RemoveCueAt(i);
}
// Add all the cues, starting from the position of the last cue that was
// added, that have valid start and end times for the current playback time.
// We can stop iterating safely once we encounter a cue that does not have
// valid times for the current playback time as the cue list is sorted.
for (; mCuePos < mCueList->Length(); mCuePos++) {
TextTrackCue* cue = (*mCueList)[mCuePos];
if (cue->StartTime() > playbackTime || cue->EndTime() < playbackTime) {
break;
}
mActiveCueList->AddCue(*cue);
}
return mActiveCueList;
}
示例2: TextTrackCueList
// https://html.spec.whatwg.org/multipage/embedded-content.html#time-marches-on
void
TextTrackManager::TimeMarchesOn()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
WEBVTT_LOG("TimeMarchesOn");
mTimeMarchesOnDispatched = false;
// Early return if we don't have any TextTracks or shutting down.
if (!mTextTracks || mTextTracks->Length() == 0 || mShutdown) {
return;
}
nsISupports* parentObject =
mMediaElement->OwnerDoc()->GetParentObject();
if (NS_WARN_IF(!parentObject)) {
return;
}
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(parentObject);
if (mMediaElement &&
(!(mMediaElement->GetPlayedOrSeeked()) || mMediaElement->Seeking())) {
WEBVTT_LOG("TimeMarchesOn seeking or post return");
return;
}
// Step 3.
double currentPlaybackTime = mMediaElement->CurrentTime();
bool hasNormalPlayback = !mHasSeeked;
mHasSeeked = false;
WEBVTT_LOG("TimeMarchesOn mLastTimeMarchesOnCalled %lf currentPlaybackTime %lf hasNormalPlayback %d"
, mLastTimeMarchesOnCalled, currentPlaybackTime, hasNormalPlayback);
// Step 1, 2.
RefPtr<TextTrackCueList> currentCues =
new TextTrackCueList(window);
RefPtr<TextTrackCueList> otherCues =
new TextTrackCueList(window);
bool dummy;
for (uint32_t index = 0; index < mTextTracks->Length(); ++index) {
TextTrack* ttrack = mTextTracks->IndexedGetter(index, dummy);
if (ttrack && dummy) {
// TODO: call GetCueListByTimeInterval on mNewCues?
ttrack->UpdateActiveCueList();
TextTrackCueList* activeCueList = ttrack->GetActiveCues();
if (activeCueList) {
for (uint32_t i = 0; i < activeCueList->Length(); ++i) {
currentCues->AddCue(*((*activeCueList)[i]));
}
}
}
}
WEBVTT_LOGV("TimeMarchesOn currentCues %d", currentCues->Length());
// Populate otherCues with 'non-active" cues.
if (hasNormalPlayback) {
if (currentPlaybackTime < mLastTimeMarchesOnCalled) {
// TODO: Add log and find the root cause why the
// playback position goes backward.
mLastTimeMarchesOnCalled = currentPlaybackTime;
}
media::Interval<double> interval(mLastTimeMarchesOnCalled,
currentPlaybackTime);
otherCues = mNewCues->GetCueListByTimeInterval(interval);;
} else {
// Seek case. Put the mLastActiveCues into otherCues.
otherCues = mLastActiveCues;
}
for (uint32_t i = 0; i < currentCues->Length(); ++i) {
TextTrackCue* cue = (*currentCues)[i];
otherCues->RemoveCue(*cue);
}
WEBVTT_LOGV("TimeMarchesOn otherCues %d", otherCues->Length());
// Step 4.
RefPtr<TextTrackCueList> missedCues = new TextTrackCueList(window);
if (hasNormalPlayback) {
for (uint32_t i = 0; i < otherCues->Length(); ++i) {
TextTrackCue* cue = (*otherCues)[i];
if (cue->StartTime() >= mLastTimeMarchesOnCalled &&
cue->EndTime() <= currentPlaybackTime) {
missedCues->AddCue(*cue);
}
}
}
WEBVTT_LOGV("TimeMarchesOn missedCues %d", missedCues->Length());
// Step 5. Empty now.
// TODO: Step 6: fire timeupdate?
// Step 7. Abort steps if condition 1, 2, 3 are satisfied.
// 1. All of the cues in current cues have their active flag set.
// 2. None of the cues in other cues have their active flag set.
// 3. Missed cues is empty.
bool c1 = true;
for (uint32_t i = 0; i < currentCues->Length(); ++i) {
if (!(*currentCues)[i]->GetActive()) {
c1 = false;
break;
}
}
bool c2 = true;
for (uint32_t i = 0; i < otherCues->Length(); ++i) {
//.........这里部分代码省略.........