Search the Community
Showing results for tags 'playvideo'.
-
function playVideo (posX, posY, width, height, url, duration, canClose, postGUI) if not posX or not posY or not width or not height or not url then return false end local webBrowser = false closeButton = guiCreateButton (0.97, 0, 0.03, 0.03, "X", true) guiSetAlpha (closeButton, 0.5) guiSetVisible (closeButton, false) if not isElement (webBrowser) then webBrowser = createBrowser (width, height, false, false) function createVideoPlayer () function webBrowserRender () dxDrawImage (posX, posY, width, height, webBrowser, 0, 0, 0, tocolor(255,255,255,255), postGUI) end loadBrowserURL (webBrowser, url) setTimer (function() addEventHandler ("onClientRender", getRootElement(), webBrowserRender) showChat (false) if canClose then guiSetVisible (closeButton, true) showCursor (true) end end, 500, 1) setElementFrozen (localPlayer, true) if duration then videoTimer = setTimer (function() removeEventHandler ("onClientRender", getRootElement(), webBrowserRender) setElementFrozen (localPlayer, false) guiSetVisible (closeButton, false) showCursor (false) showChat (true) destroyElement (webBrowser) end, duration, 1) end addEventHandler ("onClientGUIClick", closeButton, function (button, state) if button == "left" then if isTimer (videoTimer) then killTimer (videoTimer) videoTimer = nil removeEventHandler ("onClientRender", getRootElement(), webBrowserRender) setElementFrozen (localPlayer, false) guiSetVisible (closeButton, false) showCursor (false) showChat (true) destroyElement (webBrowser) end end end, false) end setTimer (createVideoPlayer, 500, 1) end end