* @brief Pause or resume playback (params: paused: bool) */
| 166 | * @brief Pause or resume playback (params: paused: bool) |
| 167 | */ |
| 168 | API::CommandResponse API::Handlers::MDF4PlayerHandler::setPaused(const QString& id, |
| 169 | const QJsonObject& params) |
| 170 | { |
| 171 | if (!params.contains(QStringLiteral("paused"))) { |
| 172 | return CommandResponse::makeError( |
| 173 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: paused")); |
| 174 | } |
| 175 | |
| 176 | const bool paused = params.value(QStringLiteral("paused")).toBool(); |
| 177 | if (paused) |
| 178 | MDF4::Player::instance().pause(); |
| 179 | else |
| 180 | MDF4::Player::instance().play(); |
| 181 | |
| 182 | QJsonObject result; |
| 183 | result[QStringLiteral("isPlaying")] = MDF4::Player::instance().isPlaying(); |
| 184 | return CommandResponse::makeSuccess(id, result); |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * @brief Step delta frames forward (or backward if negative; default 1) |