-
Notifications
You must be signed in to change notification settings - Fork 0
/
recording-indicator.py
64 lines (47 loc) · 1.75 KB
/
recording-indicator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import obspython as obs
VERSION = "v0.0.2b"
class _Functions:
def __init__(self, source_name=None):
self.source_name = source_name
def set_visible_all(self, visible):
"""Cycle through all scenes, manually toggling visibility of the source
Idea from GitHub user LukyLurks
"""
scenes = obs.obs_frontend_get_scenes()
for scene in scenes:
scene_test = obs.obs_scene_from_source(scene)
in_scene = obs.obs_scene_find_source(scene_test, self.source_name)
if in_scene:
obs.obs_sceneitem_set_visible(in_scene, visible)
obs.source_list_release(scenes)
f = _Functions()
def script_update(settings):
f.source_name = obs.obs_data_get_string(settings, "source")
def script_properties():
props = obs.obs_properties_create()
p = obs.obs_properties_add_list(
props,
"source",
"Source",
obs.OBS_COMBO_TYPE_EDITABLE,
obs.OBS_COMBO_FORMAT_STRING,
)
sources = obs.obs_enum_sources()
if sources is not None:
for source in sources:
source_id = obs.obs_source_get_unversioned_id(source)
name = obs.obs_source_get_name(source)
obs.obs_property_list_add_string(p, name, source_id)
obs.source_list_release(sources)
return props
def script_description():
return f"Show a source only when recording \n{VERSION}"
def on_event(event):
if event == obs.OBS_FRONTEND_EVENT_RECORDING_STARTED:
# Make source visible
f.set_visible_all(True)
elif event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED:
# Make source invisible again
f.set_visible_all(False)
def script_load(settings):
obs.obs_frontend_add_event_callback(on_event)