obsproject / obs-websocket

Remote-control of OBS Studio through WebSocket
GNU General Public License v2.0
3.84k stars 705 forks source link

Bug: After OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP, OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PLAY doesn't work as expected. #1046

Open tinodo opened 1 year ago

tinodo commented 1 year ago

Operating System Info

Windows 11

Other OS

No response

OBS Studio Version

Other

OBS Studio Version (Other)

28.0.3

obs-websocket Version

5.0.1

OBS Studio Log URL

https://obsproject.com/logs/I5BL7WZ0WjbXHYn_

OBS Studio Crash Log URL

No response

Expected Behavior

After calling TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP"), I expect to be able to start playing the Media Input again using TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_START").

Current Behavior

After calling TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP"), I cannot start to play the Media Input anymore using TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_START"). This is unexcepted.

Steps to Reproduce

  1. Call TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP") to stop playing a media input.
  2. Then call TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_START") to start it again.

Anything else we should know?

When using WebSockets to stop playing a media input using TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP"), I cannot start to play the Media Input anymore using TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_START"). Looking at the source code (RequestHandler_MediaInputs.cpp), I can see that the implementation is not what I would expect;

case OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PLAY:
    // Shoutout to whoever implemented this API call like this
    obs_source_media_play_pause(input, false);
    break;
case OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP:
    obs_source_media_stop(input);
    break;
case OBS_WEBSOCKET_MEDIA_INPUT_ACTION_RESTART:
    // I'm only implementing this because I'm nice. I think its a really dumb action.
    obs_source_media_restart(input);
    break;

Thanks to the developer that put in that "dumb" action called "RESTART", because actually calling "RESTART" is the only option to start playing again. If this is proper, then why have a START and a RESTART? What would be the difference?

The implementation is not what I expect, and I hope you can agree.

ALSO: After calling TriggerMediaInputAction(InputName, "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP"), I can't press PLAY in the UI anymore either... I have STOP it there and RESTART it to get it playing again...

ChristopheCVB commented 1 year ago

You may want to take a look at the freshly documented enum for OBSMediaInputAction (don't mind the deprecated warnings, it's not), because that OBS_WEBSOCKET_MEDIA_INPUT_ACTION_START doesn't exist. You have to use OBS_WEBSOCKET_MEDIA_INPUT_ACTION_RESTART after stopping a Media Input