Last active
March 20, 2018 21:41
-
-
Save Palakis/ebbe31ad98a5de13e2cf797e7ee2f972 to your computer and use it in GitHub Desktop.
OBS Studio - Global media source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obs = obslua | |
mediaSource = nil -- Null pointer | |
outputIndex = 63 -- Last index | |
-- A function named script_description returns the description shown to | |
-- the user | |
function script_description() | |
return "Plays a media source as a global source.\nSelect a file, reload the script and enjoy." | |
end | |
function script_properties() | |
local props = obs.obs_properties_create(); | |
obs.obs_properties_add_path(props, "path", "Local media path", obs.OBS_PATH_FILE, "*", 0) | |
return props | |
end | |
-- a function named script_load will be called on startup | |
function script_load(settings) | |
local sourceSettings = obs.obs_data_create() | |
obs.obs_data_set_bool(sourceSettings, "is_local_file", true) | |
obs.obs_data_set_string(sourceSettings, "local_file", obs.obs_data_get_string(settings, "path")) | |
obs.obs_data_set_bool(sourceSettings, "looping", true) | |
mediaSource = obs.obs_source_create_private("ffmpeg_source", "Global Media Source", sourceSettings) | |
obs.obs_data_release(sourceSettings) | |
obs.obs_set_output_source(outputIndex, mediaSource) | |
end | |
function script_unload() | |
obs.obs_set_output_source(outputIndex, nil) | |
obs.obs_source_release(mediaSource) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment