* @brief Seek to position */
| 260 | * @brief Seek to position |
| 261 | */ |
| 262 | API::CommandResponse API::Handlers::CSVPlayerHandler::setProgress(const QString& id, |
| 263 | const QJsonObject& params) |
| 264 | { |
| 265 | if (!params.contains(QStringLiteral("progress"))) { |
| 266 | return CommandResponse::makeError( |
| 267 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: progress")); |
| 268 | } |
| 269 | |
| 270 | const double progress = SerialStudio::toDouble(params.value(QStringLiteral("progress"))); |
| 271 | if (progress < 0.0 || progress > 1.0) { |
| 272 | return CommandResponse::makeError( |
| 273 | id, ErrorCode::InvalidParam, QStringLiteral("progress must be between 0.0 and 1.0")); |
| 274 | } |
| 275 | |
| 276 | CSV::Player::instance().setProgress(progress); |
| 277 | |
| 278 | QJsonObject result; |
| 279 | result[QStringLiteral("progress")] = CSV::Player::instance().progress(); |
| 280 | result[QStringLiteral("framePosition")] = CSV::Player::instance().framePosition(); |
| 281 | return CommandResponse::makeSuccess(id, result); |
| 282 | } |
| 283 | |
| 284 | //-------------------------------------------------------------------------------------------------- |
| 285 | // Getters |
nothing calls this directly
no test coverage detected