コード例 #1
0
def set_current_scene(scene):
	obs.obs_frontend_remove_event_callback(on_event)
	if obs.obs_frontend_preview_program_mode_active():
		obs.obs_frontend_set_current_preview_scene(scene)
	else:
		obs.obs_frontend_set_current_scene(scene)
	obs.obs_frontend_add_event_callback(on_event)
コード例 #2
0
def script_update(updatedSettings):
    """
    Called when the script’s settings (if any) have been changed by the user.
    """
    global source_name
    global scene_item
    global animationCount
    global Server
    global Animations
    global settings
    global props

    print("Script Update Called")

    try:
        settings = updatedSettings

        source_name = obs.obs_data_get_string(settings, "source")
        animationCount = obs.obs_data_get_int(settings, "animationCount")
        Server.address = obs.obs_data_get_string(settings,
                                                 Server.addressStorage)
        Server.port = obs.obs_data_get_int(settings, Server.portStorage)

        restoreAnimations(settings)

        #only remove/add events if our server thread is failing.
        #serverThreadFound = False
        #main_thread = threading.current_thread()
        # for t in threading.enumerate():
        #     if t is main_thread or t.getName().startswith('Dummy'):
        #         print('Main/Dummy Thread with name %s, id %s' % (t.getName(), t.ident))
        #         continue
        #     print('Thread with name %s, id %s' % (t.getName(), t.ident))
        #     if t != None:
        #         Server.threadId = t.ident
        #         serverThreadFound = True
        #     break

        Server.run = False
        #Server.checkServer()

        Source.processingAnimation = False
        obs.timer_remove(adjustCameraTick)
        obs.timer_add(adjustCameraTick, UpdateRateMs)

        obs.timer_remove(check_Server)
        obs.timer_add(check_Server, 10000)

        obs.timer_remove(ping_Server)
        # # # Time is in ms.
        obs.timer_add(ping_Server, (Server.closeIfNoPingInXSeconds - 1) * 1000)

        obs.obs_frontend_remove_event_callback(frontend_event)
        obs.obs_frontend_add_event_callback(frontend_event)

    except Exception as e:
        print("Exception from script_update: %s" % (e))
コード例 #3
0
def on_event(event):
    if event == obs.OBS_FRONTEND_EVENT_SCENE_CHANGED:
        if get_current_scene_name() == closing_scene:
            if manage_recording and obs.obs_frontend_recording_active():
                if stop_recording_delay == 0:
                    stop_recording()
                else:
                    obs.timer_add(stop_recording, stop_recording_delay * 1000)
            if manage_streaming and obs.obs_frontend_streaming_active():
                if stop_streaming_delay == 0:
                    stop_streaming()
                else:
                    obs.timer_add(stop_streaming, stop_streaming_delay * 1000)
        else:
            if manage_recording and obs.obs_frontend_recording_active():
                obs.timer_remove(stop_recording)
            if manage_streaming and obs.obs_frontend_streaming_active():
                obs.timer_remove(stop_streaming)
    elif not (obs.obs_frontend_streaming_active()
              or obs.obs_frontend_recording_active()) and (
                  event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTING
                  or event == obs.OBS_FRONTEND_EVENT_RECORDING_STARTING
              ) and get_current_scene_name() != start_scene:
        scenes = obs.obs_frontend_get_scenes()
        if scenes != None:
            for scene_source in scenes:
                print(str(obs.obs_source_get_type(scene_source)))
                scene_name = obs.obs_source_get_name(scene_source)
                if scene_name == start_scene:
                    print(scene_name)
                    obs.obs_frontend_set_current_scene(scene_source)
                    break
            obs.source_list_release(scenes)
    elif (event == obs.OBS_FRONTEND_EVENT_STREAMING_STOPPING
          and not obs.obs_frontend_recording_active()) or (
              event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPING
              and not obs.obs_frontend_streaming_active()):
        obs.obs_frontend_remove_event_callback(on_event)
コード例 #4
0
def script_unload():
	obs.obs_frontend_remove_event_callback(on_event)
	for hot_key in hot_keys:
		obs.obs_hotkey_unregister(hot_key['callback'])
コード例 #5
0
def script_unload():
    obs.obs_frontend_remove_event_callback(on_event)