* @brief Step delta frames forward (or backward if negative; default 1) */
| 188 | * @brief Step delta frames forward (or backward if negative; default 1) |
| 189 | */ |
| 190 | API::CommandResponse API::Handlers::MDF4PlayerHandler::step(const QString& id, |
| 191 | const QJsonObject& params) |
| 192 | { |
| 193 | const int delta = |
| 194 | params.contains(QStringLiteral("delta")) ? params.value(QStringLiteral("delta")).toInt() : 1; |
| 195 | |
| 196 | auto& player = MDF4::Player::instance(); |
| 197 | if (delta == 0) { |
| 198 | QJsonObject result; |
| 199 | result[QStringLiteral("framePosition")] = player.framePosition(); |
| 200 | return CommandResponse::makeSuccess(id, result); |
| 201 | } |
| 202 | |
| 203 | const int absDelta = std::abs(delta); |
| 204 | const bool forward = delta > 0; |
| 205 | for (int i = 0; i < absDelta; ++i) |
| 206 | if (forward) |
| 207 | player.nextFrame(); |
| 208 | else |
| 209 | player.previousFrame(); |
| 210 | |
| 211 | QJsonObject result; |
| 212 | result[QStringLiteral("framePosition")] = player.framePosition(); |
| 213 | return CommandResponse::makeSuccess(id, result); |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * @brief Seek to position |
nothing calls this directly
no test coverage detected