* @brief Seek to position */
| 217 | * @brief Seek to position |
| 218 | */ |
| 219 | API::CommandResponse API::Handlers::MDF4PlayerHandler::setProgress(const QString& id, |
| 220 | const QJsonObject& params) |
| 221 | { |
| 222 | if (!params.contains(QStringLiteral("progress"))) { |
| 223 | return CommandResponse::makeError( |
| 224 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: progress")); |
| 225 | } |
| 226 | |
| 227 | const double progress = SerialStudio::toDouble(params.value(QStringLiteral("progress"))); |
| 228 | if (progress < 0.0 || progress > 1.0) { |
| 229 | return CommandResponse::makeError( |
| 230 | id, ErrorCode::InvalidParam, QStringLiteral("progress must be between 0.0 and 1.0")); |
| 231 | } |
| 232 | |
| 233 | MDF4::Player::instance().setProgress(progress); |
| 234 | |
| 235 | QJsonObject result; |
| 236 | result[QStringLiteral("progress")] = MDF4::Player::instance().progress(); |
| 237 | result[QStringLiteral("framePosition")] = MDF4::Player::instance().framePosition(); |
| 238 | return CommandResponse::makeSuccess(id, result); |
| 239 | } |
| 240 | |
| 241 | //-------------------------------------------------------------------------------------------------- |
| 242 | // Getters |
nothing calls this directly
no test coverage detected