本文整理汇总了C++中TextTrack类的典型用法代码示例。如果您正苦于以下问题:C++ TextTrack类的具体用法?C++ TextTrack怎么用?C++ TextTrack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextTrack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ensureTextTrackCueList
void TextTrack::addCue(PassRefPtr<TextTrackCue> prpCue)
{
if (!prpCue)
return;
RefPtr<TextTrackCue> cue = prpCue;
// TODO(93143): Add spec-compliant behavior for negative time values.
if (std::isnan(cue->startTime()) || std::isnan(cue->endTime()) || cue->startTime() < 0 || cue->endTime() < 0)
return;
// 4.8.10.12.5 Text track API
// The addCue(cue) method of TextTrack objects, when invoked, must run the following steps:
// 1. If the given cue is in a text track list of cues, then remove cue from that text track
// list of cues.
TextTrack* cueTrack = cue->track();
if (cueTrack && cueTrack != this)
cueTrack->removeCue(cue.get(), ASSERT_NO_EXCEPTION);
// 2. Add cue to the method's TextTrack object's text track's text track list of cues.
cue->setTrack(this);
ensureTextTrackCueList()->add(cue);
if (m_client)
m_client->textTrackAddCue(this, cue.get());
}
示例2: oncuechangeAttrSetter
static void oncuechangeAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
TextTrack* imp = V8TextTrack::toNative(info.Holder());
transferHiddenDependency(info.Holder(), imp->oncuechange(), value, V8TextTrack::eventListenerCacheIndex);
imp->setOncuechange(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate));
return;
}
示例3: modeAttrSetter
static void modeAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
TextTrack* imp = V8TextTrack::toNative(info.Holder());
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, v, value);
imp->setMode(v);
return;
}
示例4: textTrackSelectionScore
static int textTrackSelectionScore(const TextTrack& track)
{
if (track.kind() != TextTrack::captionsKeyword() && track.kind() != TextTrack::subtitlesKeyword())
return 0;
return textTrackLanguageSelectionScore(track);
}
示例5: ensureVTTRegionList
void TextTrack::addRegion(PassRefPtr<VTTRegion> prpRegion)
{
if (!prpRegion)
return;
RefPtr<VTTRegion> region = prpRegion;
VTTRegionList* regionList = ensureVTTRegionList();
// 1. If the given region is in a text track list of regions, then remove
// region from that text track list of regions.
TextTrack* regionTrack = region->track();
if (regionTrack && regionTrack != this)
regionTrack->removeRegion(region.get(), ASSERT_NO_EXCEPTION);
// 2. If the method's TextTrack object's text track list of regions contains
// a region with the same identifier as region replace the values of that
// region's width, height, anchor point, viewport anchor point and scroll
// attributes with those of region.
VTTRegion* existingRegion = regionList->getRegionById(region->id());
if (existingRegion) {
existingRegion->updateParametersFromRegion(region.get());
return;
}
// Otherwise: add region to the method's TextTrack object's text track
// list of regions.
region->setTrack(this);
regionList->add(region);
}
示例6: PerformTrackSelection
void
TextTrackManager::HonorUserPreferencesForTrackSelection()
{
if (performedTrackSelection) {
return;
}
TextTrackKind ttKinds[] = { TextTrackKind::Captions,
TextTrackKind::Subtitles };
// Steps 1 - 3: Perform automatic track selection for different TextTrack
// Kinds.
PerformTrackSelection(ttKinds, ArrayLength(ttKinds));
PerformTrackSelection(TextTrackKind::Descriptions);
PerformTrackSelection(TextTrackKind::Chapters);
// Step 4: Set all TextTracks with a kind of metadata that are disabled
// to hidden.
for (uint32_t i = 0; i < mTextTracks->Length(); i++) {
TextTrack* track = (*mTextTracks)[i];
if (track->Kind() == TextTrackKind::Metadata && TrackIsDefault(track) &&
track->Mode() == TextTrackMode::Disabled) {
track->SetMode(TextTrackMode::Hidden);
}
}
performedTrackSelection = true;
}
示例7: mediaElement
void MediaControls::showTextTrackAtIndex(unsigned indexToEnable) {
TextTrackList* trackList = mediaElement().textTracks();
if (indexToEnable >= trackList->length())
return;
TextTrack* track = trackList->anonymousIndexedGetter(indexToEnable);
if (track && track->canBeRendered())
track->setMode(TextTrack::showingKeyword());
}
示例8: addCueCallback
static v8::Handle<v8::Value> addCueCallback(const v8::Arguments& args)
{
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
TextTrack* imp = V8TextTrack::toNative(args.Holder());
V8TRYCATCH(TextTrackCue*, cue, V8TextTrackCue::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8TextTrackCue::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
imp->addCue(cue);
return v8Undefined();
}
示例9:
void
TextTrackManager::GetTextTracksOfKind(TextTrackKind aTextTrackKind,
nsTArray<TextTrack*>& aTextTracks)
{
for (uint32_t i = 0; i < mTextTracks->Length(); i++) {
TextTrack* textTrack = (*mTextTracks)[i];
if (textTrack->Kind() == aTextTrackKind) {
aTextTracks.AppendElement(textTrack);
}
}
}
示例10: activeCuesAttrGetter
static v8::Handle<v8::Value> activeCuesAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
TextTrack* imp = V8TextTrack::toNative(info.Holder());
RefPtr<TextTrackCueList> result = imp->activeCues();
v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Undefined();
if (wrapper.IsEmpty()) {
wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
if (!wrapper.IsEmpty())
V8DOMWrapper::setNamedHiddenReference(info.Holder(), "activeCues", wrapper);
}
return wrapper;
}
示例11: textTrackLanguageSelectionScore
static int textTrackLanguageSelectionScore(const TextTrack& track)
{
if (track.language().isEmpty())
return 0;
Vector<AtomicString> languages = userPreferredLanguages();
size_t languageMatchIndex = indexOfBestMatchingLanguageInList(track.language(), languages);
if (languageMatchIndex >= languages.size())
return 0;
return languages.size() - languageMatchIndex;
}
示例12:
void
TextTrackManager::PopulatePendingList()
{
uint32_t len = mTextTracks->Length();
bool dummy;
for (uint32_t index = 0; index < len; ++index) {
TextTrack* ttrack = mTextTracks->IndexedGetter(index, dummy);
if (ttrack && ttrack->Mode() != TextTrackMode::Disabled &&
ttrack->ReadyState() == HTMLTrackElement::LOADING) {
mPendingTextTracks->AddTextTrack(ttrack);
}
}
}
示例13: ASSERT_GC_OBJECT_INHERITS
void JSTextTrack::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSTextTrack* jsTextTrack = jsCast<JSTextTrack*>(cell);
ASSERT_GC_OBJECT_INHERITS(jsTextTrack, &s_info);
COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
ASSERT(jsTextTrack->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(jsTextTrack, visitor);
TextTrack* textTrack = static_cast<TextTrack*>(jsTextTrack->impl());
visitor.addOpaqueRoot(root(textTrack));
textTrack->visitJSEventListeners(visitor);
}
示例14: anonymousIndexedGetter
TextTrack* TextTrackList::getTrackById(const AtomicString& id) {
// 4.8.10.12.5 Text track API
// The getTrackById(id) method must return the first TextTrack in the
// TextTrackList object whose id IDL attribute would return a value equal
// to the value of the id argument.
for (unsigned i = 0; i < length(); ++i) {
TextTrack* track = anonymousIndexedGetter(i);
if (String(track->id()) == id)
return track;
}
// When no tracks match the given argument, the method must return null.
return 0;
}
示例15: CompareTextTracks
void
TextTrackManager::PopulatePendingList()
{
uint32_t len = mTextTracks->Length();
bool dummy;
for (uint32_t index = 0; index < len; ++index) {
TextTrack* ttrack = mTextTracks->IndexedGetter(index, dummy);
if (ttrack && ttrack->Mode() != TextTrackMode::Disabled &&
ttrack->ReadyState() == TextTrackReadyState::Loading) {
mPendingTextTracks->AddTextTrack(ttrack,
CompareTextTracks(mMediaElement));
}
}
}