* @brief Pause or resume playback (params: paused: bool) */
| 209 | * @brief Pause or resume playback (params: paused: bool) |
| 210 | */ |
| 211 | API::CommandResponse API::Handlers::CSVPlayerHandler::setPaused(const QString& id, |
| 212 | const QJsonObject& params) |
| 213 | { |
| 214 | if (!params.contains(QStringLiteral("paused"))) { |
| 215 | return CommandResponse::makeError( |
| 216 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: paused")); |
| 217 | } |
| 218 | |
| 219 | const bool paused = params.value(QStringLiteral("paused")).toBool(); |
| 220 | if (paused) |
| 221 | CSV::Player::instance().pause(); |
| 222 | else |
| 223 | CSV::Player::instance().play(); |
| 224 | |
| 225 | QJsonObject result; |
| 226 | result[QStringLiteral("isPlaying")] = CSV::Player::instance().isPlaying(); |
| 227 | return CommandResponse::makeSuccess(id, result); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * @brief Step delta frames forward (or backward if negative; default 1) |