Jump to content

remove "onClientBrowserCreated" event


Recommended Posts

hi guys,

All of my codes are working,except removeEventHandler.What should ı do to remove the video on screen ? I'am really stuck on it.thanks for helps.

function getB()
loadBrowserURL(source, "https://www.youtube.com/")
end


addEventHandler("onClientGUIClick",root,
  function ()
local browser = guiCreateBrowser(0, 0, 1, 300, false, false, true, bbas)
local theBrowser = guiGetBrowser(browser)
if source == youbutton then
addEventHandler("onClientBrowserCreated", theBrowser,getB)
guiSetEnabled ( youbutton, false )
guiSetEnabled ( googlebutton, false )
elseif source == stopbutton then
removeEventHandler("onClientBrowserCreated", theBrowser,getB)
guiSetEnabled ( youbutton, true )
guiSetEnabled ( googlebutton,true)

end
end)

 

Link to comment
  • Moderators
function getB()
	loadBrowserURL(source, "https://www.youtube.com/")
end



local browser
function createYouTubeBrowser ()
    if not browser then
        browser = guiCreateBrowser(0, 0, 1, 300, false, false, true, bbas)
    end
    local theBrowser = guiGetBrowser(browser)
    if source == youbutton then
    	addEventHandler("onClientBrowserCreated", theBrowser,getB)
    	guiSetEnabled ( youbutton, false )
    	guiSetEnabled ( googlebutton, false )
    elseif source == stopbutton then
    	removeEventHandler("onClientBrowserCreated", theBrowser,getB)
    	guiSetEnabled ( youbutton, true )
    	guiSetEnabled ( googlebutton,true)
    end
end
addEventHandler("onClientGUIClick", stopbutton, createYouTubeBrowser)
addEventHandler("onClientGUIClick", youbutton, createYouTubeBrowser)

Something like that.

  • Problem: You created multiple browsers.
  • Tweak: Reduced event trigger rate, by attaching them to the right elements.

@SoManyTears

Link to comment
  • Moderators
3 minutes ago, SoManyTears said:

thank for your interest but still same problem.When ı press stopbutton,video still continues.I tried a lot of code, but there are still problems.

Removing the addEventHandler does not stop the video. This handler only triggers when the browser is ready to be used. This only happens 1 time, per browser.

If you want to stop playing YouTube, you could change the url or destroy the browser.

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...