halioris
New Member
Pretty new to the Lua scripting world but have a script running that does everything I need it to to all of my sources, with one annoying exception. I am changing the URL of a browser source, which it does successfully, but the actual visible content does not change. When I go open the browser source up in the UI the URL is there but it does not attempt to actually get the page until I click "OK" in the UI. I tried calling the browser cache refresh in my script which did not work (it doesn't work in the UI either). I literally have to press "OK" to get it to refresh the new site. Below is my code for the browser url update.
Funny thing is even if I hit the "Refresh cache of current page" button in the UI it just refreshes what is in the browser itself (not the URL that is currently there). For example, I had the default obsproject.com link in there and programmatically change it to another URL. When I open up the properties I see the new URL but still the old OBS blue screen as the source, and when I hit "Refresh cache of current page" it just refreshes the obs page.
Is there an event in an API provided by browser-source that has to be called. Suggestions?
Code:
function refreshBrowser(browser_source)
local properties = obs.obs_source_properties(browser_source)
local property = obs.obs_properties_get(properties, "refreshnocache")
obs.obs_property_button_clicked(property, browser_source)
obs.obs_properties_destroy(properties)
end
function updateBrowserSourceUrl(browser_source, browser_source_name, new_url)
local settings = obs.obs_source_get_settings(browser_source)
if settings ~= nil then
local current_url = obs.obs_data_get_string(settings, "url")
if current_url ~= nil then
if current_url ~= new_url then
print(" updating url for " .. browser_source_name .. " from " .. current_url .. " to " .. new_url)
obs.obs_data_set_string(settings, "url", new_url)
obs.obs_source_update(source, settings)
--refreshBrowser(source) -- did not seem to help
end
else
print(" unable to get url property")
end
obs.obs_data_release(settings)
end
end
Funny thing is even if I hit the "Refresh cache of current page" button in the UI it just refreshes what is in the browser itself (not the URL that is currently there). For example, I had the default obsproject.com link in there and programmatically change it to another URL. When I open up the properties I see the new URL but still the old OBS blue screen as the source, and when I hit "Refresh cache of current page" it just refreshes the obs page.
Is there an event in an API provided by browser-source that has to be called. Suggestions?