obs = obslua -- Инициализация функции function script_description() return "Плагин для перезапуска видео через определенный интервал времени" end -- Глобальные переменные source_name = "" interval = 60 interval_tmp = 60 timer_active = false local restart_timer = nil last_tick_time = 0 -- Функция создания и настройки UI function script_properties() local props = obs.obs_properties_create() -- Выбор источника медиа local sources = obs.obs_enum_sources() if sources ~= nil then source_list = obs.obs_properties_add_list(props, "source", "Источник медиа", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) for _, source in ipairs(sources) do source_id = obs.obs_source_get_id(source) if source_id == "ffmpeg_source" or source_id == "vlc_source" then source_name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(source_list, source_name, source_name) end end end obs.source_list_release(sources) -- Интервал времени obs.obs_properties_add_int(props, "interval", "Интервал (секунды)", 1, 3600, 1) -- Чекбокс стоп/пуск таймера obs.obs_properties_add_bool(props, "timer_active", "Стоп/Пуск таймера") return props end -- Функция обработки изменений в UI function script_update(settings) source_name = obs.obs_data_get_string(settings, "source") interval = obs.obs_data_get_int(settings, "interval") if timer_active ~= obs.obs_data_get_bool(settings, "timer_active") then timer_active = obs.obs_data_get_bool(settings, "timer_active") if timer_active then interval_tmp = interval else end end end function time_tik() local source = obs.obs_get_source_by_name(source_name) if source ~= nil then obs.obs_source_media_restart(source) obs.obs_source_release(media_source) end end function script_tick(seconds) if timer_active then local current_time = obs.os_gettime_ns() / 1e9 local elapsed_time = current_time - last_tick_time last_tick_time = current_time interval_tmp = interval_tmp - elapsed_time --obs.script_log(obs.LOG_INFO, interval_tmp) if interval_tmp <= 0 then time_tik() interval_tmp = interval end else last_tick_time = obs.os_gettime_ns() / 1e9 end end