diff --git a/README.md b/README.md index c05512ba0..3e1732802 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ window.addEventListener('obsSceneChanged', function(event) { Descriptions for these events can be [found here](https://obsproject.com/docs/reference-frontend-api.html?highlight=paused#c.obs_frontend_event). * obsSceneChanged +* obsSceneListChanged +* obsTransitionChanged +* obsTransitionListChanged * obsSourceVisibleChanged * obsSourceActiveChanged * obsStreamingStarting diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 71008f3e7..32ac2e636 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -617,6 +617,49 @@ static void handle_obs_frontend_event(enum obs_frontend_event event, void *) DispatchJSEvent("obsSceneChanged", json.dump()); break; } + case OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED: { + struct obs_frontend_source_list list = {}; + obs_frontend_get_scenes(&list); + std::vector scenes_vector; + for (size_t i = 0; i < list.sources.num; i++) { + obs_source_t *source = list.sources.array[i]; + scenes_vector.push_back(obs_source_get_name(source)); + } + nlohmann::json json = scenes_vector; + obs_frontend_source_list_free(&list); + + DispatchJSEvent("obsSceneListChanged", json.dump()); + break; + } + case OBS_FRONTEND_EVENT_TRANSITION_CHANGED: { + OBSSourceAutoRelease source = + obs_frontend_get_current_transition(); + + if (!source) + break; + + const char *name = obs_source_get_name(source); + if (!name) + break; + + DispatchJSEvent("obsTransitionChanged", name); + break; + } + case OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED: { + struct obs_frontend_source_list list = {}; + obs_frontend_get_transitions(&list); + std::vector transitions_vector; + for (size_t i = 0; i < list.sources.num; i++) { + obs_source_t *source = list.sources.array[i]; + transitions_vector.push_back( + obs_source_get_name(source)); + } + nlohmann::json json = transitions_vector; + obs_frontend_source_list_free(&list); + + DispatchJSEvent("obsTransitionListChanged", json.dump()); + break; + } case OBS_FRONTEND_EVENT_EXIT: DispatchJSEvent("obsExit", ""); break;