本文整理汇总了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();
}
}
}
示例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
}
示例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();
}
}
}
}
示例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();
}
}
}