obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
680 stars 96 forks source link

How to utilize obs-websocket 4.9.0 new events. #224

Closed samcreate closed 3 years ago

samcreate commented 3 years ago

Description:

obs-websocket has some very handy new events on media sources. Such as "MediaEnded"

This doesn't work:

obs.on("MediaStarted", (e) => { console.log("MediaStarted!", e); });

It also mentions that "These events are emitted by the OBS sources themselves" but looks like sources are just plain js objects when retrieving them with obs.send("GetSceneList")

Versions Used (if applicable):

zoton2 commented 3 years ago

I tested attaching it directly to the OBS connection and it works fine. The documentation seems to be worded weirdly; there's no way something sent over WebSocket would ever be able to output events of it's own (unless I'm mistaken).

As the release notes for 4.9.0 mention, "Only use this release with OBS Studio 26.1 or above!" so you may want to update your OBS version.

hodbauer commented 3 years ago

Hi, I have a similar issue about the d.ts of this version.

I call obs.send('GetRecordingStatus') ... And it return the expected value, but i've got typescript error that this event not exist.

The GetRecordingStatus event is part of 4.9.0 so it should not do this error.

zoton2 commented 3 years ago

Yeah the typings haven't been updated in a while, it was annoying to me too. I fixed some issues with them on my own fork and still need to make a PR, and then it'd need to be updated on npm too.

samcreate commented 3 years ago

@zoton2 Could you share what it looks like to attaching it directly to the OBS connection?

zoton2 commented 3 years ago

I was just using it like normal events. So like...

obs.on('MediaStarted', (data) => {
  /* data returned here */
});

Again, make sure your obs-studio version is up to date.

Panger95 commented 3 years ago

This issue seems to be because the obs-studio is not using version 26.1 or above.