* @brief Step delta frames forward (or backward if negative; default 1) */
| 231 | * @brief Step delta frames forward (or backward if negative; default 1) |
| 232 | */ |
| 233 | API::CommandResponse API::Handlers::CSVPlayerHandler::step(const QString& id, |
| 234 | const QJsonObject& params) |
| 235 | { |
| 236 | const int delta = |
| 237 | params.contains(QStringLiteral("delta")) ? params.value(QStringLiteral("delta")).toInt() : 1; |
| 238 | |
| 239 | auto& player = CSV::Player::instance(); |
| 240 | if (delta == 0) { |
| 241 | QJsonObject result; |
| 242 | result[QStringLiteral("framePosition")] = player.framePosition(); |
| 243 | return CommandResponse::makeSuccess(id, result); |
| 244 | } |
| 245 | |
| 246 | const int absDelta = std::abs(delta); |
| 247 | const bool forward = delta > 0; |
| 248 | for (int i = 0; i < absDelta; ++i) |
| 249 | if (forward) |
| 250 | player.nextFrame(); |
| 251 | else |
| 252 | player.previousFrame(); |
| 253 | |
| 254 | QJsonObject result; |
| 255 | result[QStringLiteral("framePosition")] = player.framePosition(); |
| 256 | return CommandResponse::makeSuccess(id, result); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * @brief Seek to position |
nothing calls this directly
no test coverage detected