canControl must be true for property requests

This commit is contained in:
badaix 2021-12-17 09:15:39 +01:00
parent be4cfd3241
commit 636b24a074
2 changed files with 14 additions and 6 deletions

View file

@ -46,17 +46,17 @@ std::string category::message(int value) const
case ControlErrc::can_not_control:
return "Stream can not be controlled";
case ControlErrc::can_go_next_is_false:
return "Stream property can_go_next is false";
return "Stream property canGoNext is false";
case ControlErrc::can_go_previous_is_false:
return "Stream property can_go_previous is false";
return "Stream property canGoPrevious is false";
case ControlErrc::can_play_is_false:
return "Stream property can_play is false";
return "Stream property canPlay is false";
case ControlErrc::can_pause_is_false:
return "Stream property can_pause is false";
return "Stream property canPause is false";
case ControlErrc::can_seek_is_false:
return "Stream property can_seek is false";
return "Stream property canSeek is false";
case ControlErrc::can_control_is_false:
return "Stream property can_control is false";
return "Stream property canControl is false";
case ControlErrc::parse_error:
return "Parse error";
case ControlErrc::invalid_request:

View file

@ -320,6 +320,8 @@ const Properties& PcmStream::getProperties() const
void PcmStream::setShuffle(bool shuffle, ResultHandler handler)
{
LOG(DEBUG, LOG_TAG) << "setShuffle: " << shuffle << "\n";
if (!properties_.can_control)
return handler({ControlErrc::can_control_is_false});
sendRequest("Plugin.Stream.Player.SetProperty", {"shuffle", shuffle}, std::move(handler));
}
@ -327,6 +329,8 @@ void PcmStream::setShuffle(bool shuffle, ResultHandler handler)
void PcmStream::setLoopStatus(LoopStatus status, ResultHandler handler)
{
LOG(DEBUG, LOG_TAG) << "setLoopStatus: " << status << "\n";
if (!properties_.can_control)
return handler({ControlErrc::can_control_is_false});
sendRequest("Plugin.Stream.Player.SetProperty", {"loopStatus", to_string(status)}, std::move(handler));
}
@ -334,6 +338,8 @@ void PcmStream::setLoopStatus(LoopStatus status, ResultHandler handler)
void PcmStream::setVolume(uint16_t volume, ResultHandler handler)
{
LOG(DEBUG, LOG_TAG) << "setVolume: " << volume << "\n";
if (!properties_.can_control)
return handler({ControlErrc::can_control_is_false});
sendRequest("Plugin.Stream.Player.SetProperty", {"volume", volume}, std::move(handler));
}
@ -341,6 +347,8 @@ void PcmStream::setVolume(uint16_t volume, ResultHandler handler)
void PcmStream::setRate(float rate, ResultHandler handler)
{
LOG(DEBUG, LOG_TAG) << "setRate: " << rate << "\n";
if (!properties_.can_control)
return handler({ControlErrc::can_control_is_false});
sendRequest("Plugin.Stream.Player.SetProperty", {"rate", rate}, std::move(handler));
}