本文整理汇总了C++中HTMLMediaElement类的典型用法代码示例。如果您正苦于以下问题:C++ HTMLMediaElement类的具体用法?C++ HTMLMediaElement怎么用?C++ HTMLMediaElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTMLMediaElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: requiresFullscreenForVideoPlayback
bool HTMLMediaSession::requiresFullscreenForVideoPlayback(const HTMLMediaElement& element) const
{
if (!MediaSessionManager::sharedManager().sessionRestrictsInlineVideoPlayback(*this))
return false;
Settings* settings = element.document().settings();
if (!settings || !settings->mediaPlaybackAllowsInline())
return true;
if (element.fastHasAttribute(HTMLNames::webkit_playsinlineAttr))
return false;
#if PLATFORM(IOS)
if (applicationIsDumpRenderTree())
return false;
#endif
return true;
}
示例2: ENABLE
bool RenderThemeWinCE::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r)
{
bool rc = RenderTheme::paintSliderThumb(o, i, r);
i.context->save();
i.context->setStrokeColor(Color::black, ColorSpaceDeviceRGB);
i.context->setFillColor(Color::black, ColorSpaceDeviceRGB);
#if ENABLE(VIDEO)
HTMLMediaElement* mediaElement = mediaElementParent(o->node());
if (mediaElement) {
float pt = (mediaElement->currentTime() - mediaElement->startTime()) / mediaElement->duration();
FloatRect intRect = r;
intRect.setX(intRect.x() + intRect.width() * pt - 2);
intRect.setWidth(5);
i.context->fillRect(intRect);
}
#endif
i.context->restore();
return rc;
}
示例3: ENABLE
void MediaControlClosedCaptionsTrackListElement::updateDisplay()
{
#if ENABLE(VIDEO_TRACK)
DEFINE_STATIC_LOCAL(AtomicString, selectedClassValue, ("selected", AtomicString::ConstructFromLiteral));
if (!mediaController()->hasClosedCaptions())
return;
HTMLMediaElement* mediaElement = toParentMediaElement(this);
if (!mediaElement)
return;
TextTrackList* trackList = mediaElement->textTracks();
if (!trackList || !trackList->length())
return;
if (m_trackListHasChanged)
rebuildTrackListMenu();
bool captionsVisible = mediaElement->closedCaptionsVisible();
for (unsigned i = 0, length = m_menuItems.size(); i < length; ++i) {
RefPtr<Element> trackItem = m_menuItems[i];
int trackIndex = trackListIndexForElement(trackItem.get());
if (trackIndex != HTMLMediaElement::textTracksIndexNotFound()) {
if (trackIndex == HTMLMediaElement::textTracksOffIndex()) {
if (captionsVisible)
trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION);
else
trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION);
} else {
TextTrack* track = trackList->item(trackIndex);
if (!track)
continue;
if (track->mode() == TextTrack::showingKeyword())
trackItem->classList()->add(selectedClassValue, ASSERT_NO_EXCEPTION);
else
trackItem->classList()->remove(selectedClassValue, ASSERT_NO_EXCEPTION);
}
}
}
#endif
}
示例4: pageAllowsPlaybackAfterResuming
bool MediaElementSession::pageAllowsPlaybackAfterResuming(const HTMLMediaElement& element) const
{
Page* page = element.document().page();
if (m_restrictions & RequirePageConsentToResumeMedia && page && !page->canStartMedia()) {
LOG(Media, "MediaElementSession::pageAllowsPlaybackAfterResuming - returning FALSE");
return false;
}
return true;
}
示例5: pageAllowsDataLoading
bool HTMLMediaSession::pageAllowsDataLoading(const HTMLMediaElement& element) const
{
Page* page = element.document().page();
if (m_restrictions & RequirePageConsentToLoadMedia && page && !page->canStartMedia()) {
LOG(Media, "HTMLMediaSession::pageAllowsDataLoading - returning FALSE");
return false;
}
return true;
}
示例6: ENABLE
void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
{
#if ENABLE(VIDEO_TRACK)
// Remove any existing content.
removeChildren();
m_menuItems.clear();
m_menuToTrackMap.clear();
if (!mediaController()->hasClosedCaptions())
return;
HTMLMediaElement* mediaElement = toParentMediaElement(this);
if (!mediaElement)
return;
TextTrackList* trackList = mediaElement->textTracks();
if (!trackList || !trackList->length())
return;
Document* doc = document();
if (!document()->page())
return;
CaptionUserPreferences* captionPreferences = document()->page()->group().captionPreferences();
Vector<RefPtr<TextTrack> > tracksForMenu = captionPreferences->sortedTrackListForMenu(trackList);
RefPtr<Element> captionsHeader = doc->createElement(h3Tag, ASSERT_NO_EXCEPTION);
captionsHeader->appendChild(doc->createTextNode(textTrackSubtitlesText()));
appendChild(captionsHeader);
RefPtr<Element> captionsMenuList = doc->createElement(ulTag, ASSERT_NO_EXCEPTION);
for (unsigned i = 0, length = tracksForMenu.size(); i < length; ++i) {
RefPtr<TextTrack> textTrack = tracksForMenu[i];
RefPtr<Element> menuItem = doc->createElement(liTag, ASSERT_NO_EXCEPTION);
menuItem->appendChild(doc->createTextNode(captionPreferences->displayNameForTrack(textTrack.get())));
captionsMenuList->appendChild(menuItem);
m_menuItems.append(menuItem);
m_menuToTrackMap.add(menuItem, textTrack);
}
appendChild(captionsMenuList);
#endif
}
示例7: switch
int MediaPlayerPrivate::showErrorDialog(MMRPlayer::Error type)
{
using namespace BlackBerry::WebKit;
WebPageClient::AlertType atype;
switch (type) {
case MMRPlayer::MediaOK:
atype = WebPageClient::MediaOK;
break;
case MMRPlayer::MediaDecodeError:
atype = WebPageClient::MediaDecodeError;
break;
case MMRPlayer::MediaMetaDataError:
atype = WebPageClient::MediaMetaDataError;
break;
case MMRPlayer::MediaMetaDataTimeoutError:
atype = WebPageClient::MediaMetaDataTimeoutError;
break;
case MMRPlayer::MediaNoMetaDataError:
atype = WebPageClient::MediaNoMetaDataError;
break;
case MMRPlayer::MediaVideoReceiveError:
atype = WebPageClient::MediaVideoReceiveError;
break;
case MMRPlayer::MediaAudioReceiveError:
atype = WebPageClient::MediaAudioReceiveError;
break;
case MMRPlayer::MediaInvalidError:
atype = WebPageClient::MediaInvalidError;
break;
default:
LOG(Media, "Alert type does not exist.");
return -1;
}
int rc = 0;
HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
Document* topdoc = element->document()->topDocument();
if (topdoc->view() && topdoc->view()->hostWindow())
rc = topdoc->view()->hostWindow()->platformPageClient()->showAlertDialog(atype);
return rc;
}
示例8: NS_ENSURE_SUCCESS
nsresult
HTMLSourceElement::BindToTree(nsIDocument *aDocument,
nsIContent *aParent,
nsIContent *aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument,
aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (!aParent || !aParent->IsNodeOfType(nsINode::eMEDIA))
return NS_OK;
HTMLMediaElement* media = static_cast<HTMLMediaElement*>(aParent);
media->NotifyAddedSource();
return NS_OK;
}
示例9: canControlControlsManager
bool MediaElementSession::canControlControlsManager(const HTMLMediaElement& element) const
{
if (!element.hasAudio())
return false;
if (!playbackPermitted(element))
return false;
RenderBox* renderer = downcast<RenderBox>(element.renderer());
if (!renderer)
return false;
if (isElementLargeEnoughForMainContent(element))
return true;
if (ScriptController::processingUserGestureForMedia())
return true;
return false;
}
示例10: shouldShowFullscreenButton
static bool shouldShowFullscreenButton(const HTMLMediaElement& mediaElement) {
// Unconditionally allow the user to exit fullscreen if we are in it
// now. Especially on android, when we might not yet know if
// fullscreen is supported, we sometimes guess incorrectly and show
// the button earlier, and we don't want to remove it here if the
// user chose to enter fullscreen. crbug.com/500732 .
if (mediaElement.isFullscreen())
return true;
if (!mediaElement.isHTMLVideoElement())
return false;
if (!mediaElement.hasVideo())
return false;
if (!Fullscreen::fullscreenEnabled(mediaElement.document()))
return false;
return true;
}
示例11: AudioHandler
MediaElementAudioSourceHandler::MediaElementAudioSourceHandler(
AudioNode& node,
HTMLMediaElement& mediaElement)
: AudioHandler(NodeTypeMediaElementAudioSource,
node,
node.context()->sampleRate()),
m_mediaElement(mediaElement),
m_sourceNumberOfChannels(0),
m_sourceSampleRate(0),
m_passesCurrentSrcCORSAccessCheck(
passesCurrentSrcCORSAccessCheck(mediaElement.currentSrc())),
m_maybePrintCORSMessage(!m_passesCurrentSrcCORSAccessCheck),
m_currentSrcString(mediaElement.currentSrc().getString()) {
DCHECK(isMainThread());
// Default to stereo. This could change depending on what the media element
// .src is set to.
addOutput(2);
initialize();
}
示例12: allowsAutomaticMediaDataLoading
bool MediaElementSession::allowsAutomaticMediaDataLoading(const HTMLMediaElement& element) const
{
if (pageExplicitlyAllowsElementToAutoplayInline(element))
return true;
Settings* settings = element.document().settings();
if (settings && settings->mediaDataLoadsAutomatically())
return true;
return false;
}
示例13: isElementLargeRelativeToMainFrame
static bool isElementLargeRelativeToMainFrame(const HTMLMediaElement& element)
{
static const double minimumPercentageOfMainFrameAreaForMainContent = 0.9;
auto* renderer = element.renderer();
if (!renderer)
return false;
auto* documentFrame = element.document().frame();
if (!documentFrame)
return false;
if (!documentFrame->mainFrame().view())
return false;
auto& mainFrameView = *documentFrame->mainFrame().view();
auto maxVisibleClientWidth = std::min(renderer->clientWidth().toInt(), mainFrameView.visibleWidth());
auto maxVisibleClientHeight = std::min(renderer->clientHeight().toInt(), mainFrameView.visibleHeight());
return maxVisibleClientWidth * maxVisibleClientHeight > minimumPercentageOfMainFrameAreaForMainContent * mainFrameView.visibleWidth() * mainFrameView.visibleHeight();
}
示例14: ENABLE
KURL HitTestResult::absoluteMediaURL() const
{
#if ENABLE(VIDEO)
if (!(m_innerNonSharedNode && m_innerNonSharedNode->document()))
return KURL();
if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->isMedia()))
return KURL();
AtomicString urlString;
if (m_innerNonSharedNode->hasTagName(HTMLNames::videoTag) || m_innerNonSharedNode->hasTagName(HTMLNames::audioTag)) {
HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(m_innerNonSharedNode.get());
urlString = mediaElement->currentSrc();
} else
return KURL();
return m_innerNonSharedNode->document()->completeURL(deprecatedParseURL(urlString));
#else
return KURL();
#endif
}
示例15: WTF_LOG
void HTMLMediaElementEncryptedMedia::keyAdded(HTMLMediaElement& element, const String& keySystem, const String& sessionId)
{
WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::mediaPlayerKeyAdded");
MediaKeyEventInit initializer;
initializer.setKeySystem(keySystem);
initializer.setSessionId(sessionId);
RefPtrWillBeRawPtr<Event> event = MediaKeyEvent::create(EventTypeNames::webkitkeyadded, initializer);
event->setTarget(&element);
element.scheduleEvent(event.release());
}