MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setProgress

Method setProgress

app/src/API/Handlers/MDF4PlayerHandler.cpp:219–239  ·  view source on GitHub ↗

* @brief Seek to position */

Source from the content-addressed store, hash-verified

217 * @brief Seek to position
218 */
219API::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

Callers

nothing calls this directly

Calls 4

containsMethod · 0.45
valueMethod · 0.45
progressMethod · 0.45
framePositionMethod · 0.45

Tested by

no test coverage detected