本文整理汇总了C++中video::VideoDecoder::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoDecoder::stop方法的具体用法?C++ VideoDecoder::stop怎么用?C++ VideoDecoder::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类video::VideoDecoder
的用法示例。
在下文中一共展示了VideoDecoder::stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playVideo
void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, bool skippable, Subtitle *sub) {
Common::Rect dst = destRect;
// If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
if (dst.isEmpty())
dst = Common::Rect(vid.getWidth(), vid.getHeight());
Graphics::Surface scaled;
if (vid.getWidth() != dst.width() || vid.getHeight() != dst.height())
scaled.create(dst.width(), dst.height(), vid.getPixelFormat());
uint16 x = _workingWindow.left + dst.left;
uint16 y = _workingWindow.top + dst.top;
uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width();
uint16 finalHeight = dst.height() < _workingWindow.height() ? dst.height() : _workingWindow.height();
bool showSubs = (_scriptManager->getStateValue(StateKey_Subtitles) == 1);
_clock.stop();
vid.start();
_videoIsPlaying = true;
// Only continue while the video is still playing
while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
// Check for engine quit and video stop key presses
while (_eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_KEYDOWN:
switch (_event.kbd.keycode) {
case Common::KEYCODE_q:
if (_event.kbd.hasFlags(Common::KBD_CTRL))
quitGame();
break;
case Common::KEYCODE_SPACE:
if (skippable) {
vid.stop();
}
break;
default:
break;
}
default:
break;
}
}
if (vid.needsUpdate()) {
const Graphics::Surface *frame = vid.decodeNextFrame();
if (sub && showSubs)
sub->process(vid.getCurFrame());
if (frame) {
if (scaled.getPixels()) {
_renderManager->scaleBuffer(frame->getPixels(), scaled.getPixels(), frame->getWidth(), frame->getHeight(), frame->getFormat().bytesPerPixel, scaled.getWidth(), scaled.getHeight());
frame = &scaled;
}
Common::Rect rect = Common::Rect(x, y, x + finalWidth, y + finalHeight);
_renderManager->copyToScreen(*frame, rect, 0, 0);
_renderManager->processSubs(0);
}
}
// Always update the screen so the mouse continues to render
_system->updateScreen();
_system->delayMillis(vid.getTimeToNextFrame() / 2);
}
_videoIsPlaying = false;
_clock.start();
}
示例2: playVideo
void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) {
byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
uint16 origWidth = videoDecoder.getWidth();
uint16 origHeight = videoDecoder.getHeight();
uint scale = 1;
// If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
if (destRect.isEmpty()) {
// Most videos are very small. Therefore we do a simple 2x scale
if (origWidth * 2 <= 640 && origHeight * 2 <= 480) {
scale = 2;
}
} else {
// Assume bilinear scaling. AKA calculate the scale from just the width.
// Also assume that the scaling is in integral intervals. AKA no 1.5x scaling
// TODO: Test ^these^ assumptions
scale = destRect.width() / origWidth;
// TODO: Test if we need to support downscale.
}
uint16 pitch = origWidth * bytesPerPixel;
uint16 finalWidth = origWidth * scale;
uint16 finalHeight = origHeight * scale;
byte *scaledVideoFrameBuffer;
if (scale != 1) {
scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
}
uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left;
uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top;
_clock.stop();
videoDecoder.start();
// Only continue while the video is still playing
while (!shouldQuit() && !videoDecoder.endOfVideo() && videoDecoder.isPlaying()) {
// Check for engine quit and video stop key presses
while (!videoDecoder.endOfVideo() && videoDecoder.isPlaying() && _eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_KEYDOWN:
switch (_event.kbd.keycode) {
case Common::KEYCODE_q:
if (_event.kbd.hasFlags(Common::KBD_CTRL))
quitGame();
break;
case Common::KEYCODE_SPACE:
if (skippable) {
videoDecoder.stop();
}
break;
default:
break;
}
default:
break;
}
}
if (videoDecoder.needsUpdate()) {
const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
if (frame) {
if (scale != 1) {
scaleBuffer((const byte *)frame->getPixels(), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
} else {
_system->copyRectToScreen((const byte *)frame->getPixels(), pitch, x, y, finalWidth, finalHeight);
}
}
}
// Always update the screen so the mouse continues to render
_system->updateScreen();
_system->delayMillis(videoDecoder.getTimeToNextFrame());
}
_clock.start();
if (scale != 1) {
delete[] scaledVideoFrameBuffer;
}
}