Add GetTransitionPosition

Gets the current position of the active transition. Works on manual and also auto transition modes
This commit is contained in:
tt2468 2020-05-13 23:33:59 -07:00
parent ff21f5b357
commit 56371a7d80
3 changed files with 23 additions and 3 deletions

View File

@ -84,6 +84,7 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
{ "SetCurrentTransition", &WSRequestHandler::SetCurrentTransition },
{ "SetTransitionDuration", &WSRequestHandler::SetTransitionDuration },
{ "GetTransitionDuration", &WSRequestHandler::GetTransitionDuration },
{ "GetTransitionPosition", &WSRequestHandler::GetTransitionPosition },
{ "SetVolume", &WSRequestHandler::SetVolume },
{ "GetVolume", &WSRequestHandler::GetVolume },

View File

@ -99,6 +99,9 @@ class WSRequestHandler {
RpcResponse GetTransitionList(const RpcRequest&);
RpcResponse GetCurrentTransition(const RpcRequest&);
RpcResponse SetCurrentTransition(const RpcRequest&);
RpcResponse SetTransitionDuration(const RpcRequest&);
RpcResponse GetTransitionDuration(const RpcRequest&);
RpcResponse GetTransitionPosition(const RpcRequest&);
RpcResponse SetVolume(const RpcRequest&);
RpcResponse GetVolume(const RpcRequest&);
@ -138,9 +141,6 @@ class WSRequestHandler {
RpcResponse SendCaptions(const RpcRequest&);
#endif
RpcResponse SetTransitionDuration(const RpcRequest&);
RpcResponse GetTransitionDuration(const RpcRequest&);
RpcResponse GetStudioModeStatus(const RpcRequest&);
RpcResponse GetPreviewScene(const RpcRequest&);
RpcResponse SetPreviewScene(const RpcRequest&);

View File

@ -120,3 +120,22 @@ RpcResponse WSRequestHandler::GetTransitionDuration(const RpcRequest& request) {
obs_data_set_int(response, "transition-duration", obs_frontend_get_transition_duration());
return request.success(response);
}
/**
* Get the position of the current transition.
*
* @return {double} `position` current transition position. This value will be between 0.0 and 1.0. Note: Transition returns 1.0 when not active.
*
* @api requests
* @name GetTransitionPosition
* @category transitions
* @since 4.8.0
*/
RpcResponse WSRequestHandler::GetTransitionPosition(const RpcRequest& request) {
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
OBSDataAutoRelease response = obs_data_create();
obs_data_set_double(response, "position", obs_transition_get_time(currentTransition));
return request.success(response);
}