SetBrowserVolume: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This function sets either a specific browser's volume, or the overall volume for browsers. ==Syntax== <syntaxhighlight lang="lua"> bool set...")
 
m (Link to the Romanian translation of this page added.)
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__
{{Client function}}
{{Client function}}
__NOTOC__
{{New feature/item|3.0150|1.5||
This function sets either a specific [[Element/Browser|browser]]'s volume, or the overall volume for browsers.
This function sets either a specific [[Element/Browser|browser]]'s volume, or the overall volume for browsers.
}}


==Syntax==
==Syntax==
Line 7: Line 9:
bool setBrowserVolume ( [browser webBrowser], float volume )
bool setBrowserVolume ( [browser webBrowser], float volume )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Element/Browser|browser]]:setVolume|volume|getBrowserVolume}}


===Required Arguments===
===Required Arguments===
Line 16: Line 19:
==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--todo
--In order to render the browser on the full screen, we need to know the dimensions.
local screenWidth, screenHeight = guiGetScreenSize()
--Let's create a new browser in remote mode.
local webBrowser = createBrowser(screenWidth, screenHeight, false, false)
--Function to render the browser.
function webBrowserRender()
--Render the browser on the full size of the screen.
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end
--The event onClientBrowserCreated will be triggered, after the browser has been initialized.
--After this event has been triggered, we will be able to load our URL and start drawing.
addEventHandler("onClientBrowserCreated", webBrowser,
function()
--After the browser has been initialized, we can load www.youtube.com
loadBrowserURL(webBrowser, "http://www.youtube.com")
--Now we can start to render the browser.
addEventHandler("onClientRender", root, webBrowserRender)
end
)
 
addCommandHandler ("volume", -- Add command named 'volume'
  function (command, value)
    if tonumber (value) then -- checking if the value is a number
      setBrowserVolume (webBrowser, value) -- setting the volume value
    else -- if there is no value
      outputChatBox ("You must enter a value.")
    end
  end
)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{CEF_functions}}
{{CEF_functions}}
[[hu:setBrowserVolume]]
[[RO:setBrowserVolume]]

Latest revision as of 15:15, 8 April 2020

This function sets either a specific browser's volume, or the overall volume for browsers.

Syntax

bool setBrowserVolume ( [browser webBrowser], float volume )

OOP Syntax Help! I don't understand this!

Method: browser:setVolume(...)
Variable: .volume
Counterpart: getBrowserVolume


Required Arguments

  • volume: A floating point number representing the desired volume level. Range is from 0.0 to 1.0

Optional Arguments

  • webBrowser: A browser element

Example

--In order to render the browser on the full screen, we need to know the dimensions.
local screenWidth, screenHeight = guiGetScreenSize()
 
--Let's create a new browser in remote mode.
local webBrowser = createBrowser(screenWidth, screenHeight, false, false)
 
--Function to render the browser.
function webBrowserRender()
	--Render the browser on the full size of the screen.
	dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end
 
--The event onClientBrowserCreated will be triggered, after the browser has been initialized.
--After this event has been triggered, we will be able to load our URL and start drawing.
addEventHandler("onClientBrowserCreated", webBrowser, 
	function()
		--After the browser has been initialized, we can load www.youtube.com
		loadBrowserURL(webBrowser, "http://www.youtube.com")
		--Now we can start to render the browser.
		addEventHandler("onClientRender", root, webBrowserRender)
	end
)

addCommandHandler ("volume", -- Add command named 'volume'
  function (command, value)
    if tonumber (value) then -- checking if the value is a number
      setBrowserVolume (webBrowser, value) -- setting the volume value
    else -- if there is no value
      outputChatBox ("You must enter a value.")
    end
  end
)

See Also