本文整理汇总了C++中HTMLMediaElement::buffered方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLMediaElement::buffered方法的具体用法?C++ HTMLMediaElement::buffered怎么用?C++ HTMLMediaElement::buffered使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLMediaElement
的用法示例。
在下文中一共展示了HTMLMediaElement::buffered方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintMediaSliderTrack
bool RenderThemeGtk::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
HTMLMediaElement* mediaElement = toParentMediaElement(o);
if (!mediaElement)
return false;
GraphicsContext* context = paintInfo.context;
context->save();
context->setStrokeStyle(NoStroke);
float mediaDuration = mediaElement->duration();
float totalTrackWidth = r.width();
RenderStyle* style = o->style();
RefPtr<TimeRanges> timeRanges = mediaElement->buffered();
for (unsigned index = 0; index < timeRanges->length(); ++index) {
float start = timeRanges->start(index, IGNORE_EXCEPTION);
float end = timeRanges->end(index, IGNORE_EXCEPTION);
float startRatio = start / mediaDuration;
float lengthRatio = (end - start) / mediaDuration;
if (!lengthRatio)
continue;
IntRect rangeRect(r);
rangeRect.setWidth(lengthRatio * totalTrackWidth);
if (index)
rangeRect.move(startRatio * totalTrackWidth, 0);
context->fillRoundedRect(RoundedRect(rangeRect, borderRadiiFromStyle(style)), style->visitedDependentColor(CSSPropertyColor), style->colorSpace());
}
context->restore();
return false;
}
示例2: paintMediaSliderTrack
bool RenderThemeGtk::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
GraphicsContext* context = paintInfo.context;
context->fillRect(FloatRect(r), m_panelColor, ColorSpaceDeviceRGB);
context->fillRect(FloatRect(IntRect(r.x(), r.y() + (r.height() - m_mediaSliderHeight) / 2,
r.width(), m_mediaSliderHeight)), m_sliderColor, ColorSpaceDeviceRGB);
RenderStyle* style = o->style();
HTMLMediaElement* mediaElement = toParentMediaElement(o);
if (!mediaElement)
return false;
// Draw the buffered ranges. This code is highly inspired from
// Chrome for the gradient code.
float mediaDuration = mediaElement->duration();
RefPtr<TimeRanges> timeRanges = mediaElement->buffered();
IntRect trackRect = r;
int totalWidth = trackRect.width();
trackRect.inflate(-style->borderLeftWidth());
context->save();
context->setStrokeStyle(NoStroke);
for (unsigned index = 0; index < timeRanges->length(); ++index) {
ExceptionCode ignoredException;
float start = timeRanges->start(index, ignoredException);
float end = timeRanges->end(index, ignoredException);
int width = ((end - start) * totalWidth) / mediaDuration;
IntRect rangeRect;
if (!index) {
rangeRect = trackRect;
rangeRect.setWidth(width);
} else {
rangeRect.setLocation(IntPoint(trackRect.x() + start / mediaDuration* totalWidth, trackRect.y()));
rangeRect.setSize(IntSize(width, trackRect.height()));
}
// Don't bother drawing empty range.
if (rangeRect.isEmpty())
continue;
IntPoint sliderTopLeft = rangeRect.location();
IntPoint sliderTopRight = sliderTopLeft;
sliderTopRight.move(0, rangeRect.height());
RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight);
Color startColor = m_panelColor;
gradient->addColorStop(0.0, startColor);
gradient->addColorStop(1.0, Color(startColor.red() / 2, startColor.green() / 2, startColor.blue() / 2, startColor.alpha()));
context->setFillGradient(gradient);
context->fillRect(rangeRect);
}
context->restore();
return false;
}
示例3: jsHTMLMediaElementBuffered
JSValue jsHTMLMediaElementBuffered(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSHTMLMediaElement* castedThis = static_cast<JSHTMLMediaElement*>(asObject(slotBase));
UNUSED_PARAM(exec);
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(castedThis->impl());
JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->buffered()));
return result;
}
示例4: paintMediaSlider
static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
HTMLMediaElement* mediaElement = toParentMediaElement(object);
if (!mediaElement)
return false;
RenderStyle* style = object->style();
GraphicsContext* context = paintInfo.context;
paintRoundedSliderBackground(rect, style, context);
// Draw the buffered range. Since the element may have multiple buffered ranges and it'd be
// distracting/'busy' to show all of them, show only the buffered range containing the current play head.
RefPtr<TimeRanges> bufferedTimeRanges = mediaElement->buffered();
float duration = mediaElement->duration();
float currentTime = mediaElement->currentTime();
if (std::isnan(duration) || std::isinf(duration) || !duration || std::isnan(currentTime))
return true;
for (unsigned i = 0; i < bufferedTimeRanges->length(); ++i) {
float start = bufferedTimeRanges->start(i, ASSERT_NO_EXCEPTION);
float end = bufferedTimeRanges->end(i, ASSERT_NO_EXCEPTION);
if (std::isnan(start) || std::isnan(end) || start > currentTime || end < currentTime)
continue;
int startPosition = int(start * rect.width() / duration);
int currentPosition = int(currentTime * rect.width() / duration);
int endPosition = int(end * rect.width() / duration);
// Add half the thumb width proportionally adjusted to the current painting position.
int thumbCenter = mediaSliderThumbWidth / 2;
int addWidth = thumbCenter * (1.0 - 2.0 * currentPosition / rect.width());
currentPosition += addWidth;
// Draw white-ish highlight before current time.
Color startColor = Color(195, 195, 195);
Color endColor = Color(217, 217, 217);
if (currentPosition > startPosition)
paintSliderRangeHighlight(rect, style, context, startPosition, currentPosition, startColor, endColor);
// Draw grey-ish highlight after current time.
startColor = Color(60, 60, 60);
endColor = Color(76, 76, 76);
if (endPosition > currentPosition)
paintSliderRangeHighlight(rect, style, context, currentPosition, endPosition, startColor, endColor);
return true;
}
return true;
}
示例5: getValueProperty
JSValue* JSHTMLMediaElement::getValueProperty(ExecState* exec, int token) const
{
switch (token) {
case ErrorAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return toJS(exec, WTF::getPtr(imp->error()));
}
case SrcAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsString(exec, imp->src());
}
case CurrentSrcAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsString(exec, imp->currentSrc());
}
case NetworkStateAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->networkState());
}
case BufferingRateAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->bufferingRate());
}
case BufferedAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return toJS(exec, WTF::getPtr(imp->buffered()));
}
case ReadyStateAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->readyState());
}
case SeekingAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsBoolean(imp->seeking());
}
case CurrentTimeAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->currentTime());
}
case DurationAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->duration());
}
case PausedAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsBoolean(imp->paused());
}
case DefaultPlaybackRateAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->defaultPlaybackRate());
}
case PlaybackRateAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->playbackRate());
}
case PlayedAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return toJS(exec, WTF::getPtr(imp->played()));
}
case SeekableAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return toJS(exec, WTF::getPtr(imp->seekable()));
}
case EndedAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsBoolean(imp->ended());
}
case AutoplayAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsBoolean(imp->autoplay());
}
case StartAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->start());
}
case EndAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->end());
}
case LoopStartAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->loopStart());
}
case LoopEndAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->loopEnd());
}
case PlayCountAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->playCount());
}
case CurrentLoopAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsNumber(exec, imp->currentLoop());
}
case ControlsAttrNum: {
HTMLMediaElement* imp = static_cast<HTMLMediaElement*>(impl());
return jsBoolean(imp->controls());
}
case VolumeAttrNum: {
//.........这里部分代码省略.........