SoManyTears Posted April 10, 2020 Share Posted April 10, 2020 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 IIYAMA Posted April 10, 2020 Moderators Share Posted April 10, 2020 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
SoManyTears Posted April 10, 2020 Author Share Posted April 10, 2020 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. Link to comment
Moderators IIYAMA Posted April 10, 2020 Moderators Share Posted April 10, 2020 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
SoManyTears Posted April 10, 2020 Author Share Posted April 10, 2020 thank it was very helpful 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now