-- Gerenciamento do Browser CEF theBrowser = nil local blankUrl = "http://mta/local/blank.html" local currentUrl = "" -- Lista de domínios permitidos local allowedDomains = { "api.metropolescityrp.com.br", "music.metropolescityrp.com.br", "cdn.jsdelivr.net", "www.youtube.com" } -- Retorna a textura do browser para o render function getBrowserTexture() if isElement(theBrowser) then return theBrowser end return nil end -- Inicializa o browser e solicita domínios addEventHandler("onClientResourceStart", resourceRoot, function() requestBrowserDomains(allowedDomains) -- Cria o browser remoto (isLocal = false) theBrowser = createBrowser(1280, 720, false, true) outputDebugString("[Metropoles]telao: Solicitando domínios...") end) -- Quando o browser é criado com sucesso addEventHandler("onClientBrowserCreated", resourceRoot, function() if source ~= theBrowser then return end outputDebugString("[Metropoles]telao: Browser criado com sucesso!") loadBrowserURL(theBrowser, blankUrl) end) -- Carrega a URL no browser function playVideoUrl(url) currentUrl = url if isElement(theBrowser) then outputDebugString("[Metropoles]telao: Carregando URL: " .. tostring(url)) if addDebugInfo then addDebugInfo("currentUrl", url) end loadBrowserURL(theBrowser, url) else outputDebugString("[Metropoles]telao: Browser não existe!", 1) end end -- Para o vídeo function stopVideo() currentUrl = "" if isElement(theBrowser) then outputDebugString("[Metropoles]telao: Parando vídeo") if addDebugInfo then addDebugInfo("currentUrl", "Nenhuma") end loadBrowserURL(theBrowser, blankUrl) end end -- Rastreia falhas de carregamento addEventHandler("onClientBrowserLoadingFailed", resourceRoot, function(url, errorCode, errorDescription) if source ~= theBrowser then return end outputDebugString("[Metropoles]telao: Falha ao carregar " .. url .. " (Erro " .. errorCode .. ": " .. errorDescription .. ")", 2) end)