当前位置: 首页>>代码示例>>C++>>正文


C++ HTMLVideoElement::canPlay方法代码示例

本文整理汇总了C++中HTMLVideoElement::canPlay方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLVideoElement::canPlay方法的具体用法?C++ HTMLVideoElement::canPlay怎么用?C++ HTMLVideoElement::canPlay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLVideoElement的用法示例。


在下文中一共展示了HTMLVideoElement::canPlay方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: defaultEventHandler

void MediaDocument::defaultEventHandler(Event* event)
{
    // Match the default Quicktime plugin behavior to allow 
    // clicking and double-clicking to pause and play the media.
    Node* targetNode = event->target()->toNode();
    if (!targetNode)
        return;

    HTMLVideoElement* video = descendentVideoElement(targetNode);
    if (!video)
        return;

    if (event->type() == eventNames().clickEvent) {
        if (!video->canPlay()) {
            video->pause(event->fromUserGesture());
            event->setDefaultHandled();
        }
    } else if (event->type() == eventNames().dblclickEvent) {
        if (video->canPlay()) {
            video->play(event->fromUserGesture());
            event->setDefaultHandled();
        }
    } else if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
        KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
        if (keyboardEvent->keyIdentifier() == "U+0020") { // space
            if (video->paused()) {
                if (video->canPlay())
                    video->play(event->fromUserGesture());
            } else
                video->pause(event->fromUserGesture());
            event->setDefaultHandled();
        }
    }
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:34,代码来源:MediaDocument.cpp

示例2: defaultEventHandler

void MediaDocument::defaultEventHandler(Event* event)
{
#if !(PLATFORM(BLACKBERRY) && OS(QNX))
    // Match the default Quicktime plugin behavior to allow 
    // clicking and double-clicking to pause and play the media.
    Node* targetNode = event->target()->toNode();
    if (targetNode && targetNode->hasTagName(videoTag)) {
        HTMLVideoElement* video = static_cast<HTMLVideoElement*>(targetNode);
        if (event->type() == eventNames().clickEvent) {
            if (!video->canPlay()) {
                video->pause(event->fromUserGesture());
                event->setDefaultHandled();
            }
        } else if (event->type() == eventNames().dblclickEvent) {
            if (video->canPlay()) {
                video->play(event->fromUserGesture());
                event->setDefaultHandled();
            }
        }
    }

    if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
        HTMLVideoElement* video = 0;
        if (targetNode) {
            if (targetNode->hasTagName(videoTag))
                video = static_cast<HTMLVideoElement*>(targetNode);
            else {
                RefPtr<NodeList> nodeList = targetNode->getElementsByTagName("video");
                if (nodeList.get()->length() > 0)
                    video = static_cast<HTMLVideoElement*>(nodeList.get()->item(0));
            }
        }
        if (video) {
            KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
            if (keyboardEvent->keyIdentifier() == "U+0020") { // space
                if (video->paused()) {
                    if (video->canPlay())
                        video->play(event->fromUserGesture());
                } else
                    video->pause(event->fromUserGesture());
                event->setDefaultHandled();
            }
        }
    }
#endif
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例3: defaultEventHandler

void MediaDocument::defaultEventHandler(Event* event)
{
    // Match the default Quicktime plugin behavior to allow 
    // clicking and double-clicking to pause and play the media.
    Node* targetNode = event->target()->toNode();
    if (targetNode && targetNode->hasTagName(videoTag)) {
        HTMLVideoElement* video = static_cast<HTMLVideoElement*>(targetNode);
        ExceptionCode ec;
        if (event->type() == eventNames().clickEvent) {
            if (!video->canPlay()) {
                video->pause(ec);
                event->setDefaultHandled();
            }
        } else if (event->type() == eventNames().dblclickEvent) {
            if (video->canPlay()) {
                video->play(ec);
                event->setDefaultHandled();
            }
        }
    }
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:21,代码来源:MediaDocument.cpp

示例4: defaultEventHandler

void MediaDocument::defaultEventHandler(Event* event)
{
    // Match the default Quicktime plugin behavior to allow 
    // clicking and double-clicking to pause and play the media.
    Node* targetNode = event->target()->toNode();
    if (!targetNode)
        return;

    if (HTMLVideoElement* video = ancestorVideoElement(targetNode)) {
        if (event->type() == eventNames().clickEvent) {
            if (!video->canPlay()) {
                video->pause();
                event->setDefaultHandled();
            }
        } else if (event->type() == eventNames().dblclickEvent) {
            if (video->canPlay()) {
                video->play();
                event->setDefaultHandled();
            }
        }
    }

    if (!is<ContainerNode>(*targetNode))
        return;
    ContainerNode& targetContainer = downcast<ContainerNode>(*targetNode);
    if (event->type() == eventNames().keydownEvent && is<KeyboardEvent>(*event)) {
        HTMLVideoElement* video = descendantVideoElement(targetContainer);
        if (!video)
            return;

        KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event);
        if (keyboardEvent.keyIdentifier() == "U+0020") { // space
            if (video->paused()) {
                if (video->canPlay())
                    video->play();
            } else
                video->pause();
            keyboardEvent.setDefaultHandled();
        }
    }
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:41,代码来源:MediaDocument.cpp


注:本文中的HTMLVideoElement::canPlay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。