UrlLoader:setStreaming: Difference between revisions
From GiderosMobile
m Text replacement - "<source" to "<syntaxhighlight" |
mNo edit summary |
||
| Line 7: | Line 7: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
UrlLoader:setStreaming(bool) | UrlLoader:setStreaming(bool) | ||
</ | </syntaxhighlight> | ||
=== Parameters === | === Parameters === | ||
| Line 34: | Line 34: | ||
loader:load("http://soundimage.org/wp-content/uploads/2017/08/Bubble-Gum-Puzzler.mp3") | loader:load("http://soundimage.org/wp-content/uploads/2017/08/Bubble-Gum-Puzzler.mp3") | ||
</ | </syntaxhighlight> | ||
{{UrlLoader}} | {{UrlLoader}} | ||
Latest revision as of 09:39, 27 July 2026
Available since: Gideros 2020.2
Class: UrlLoader
Description
Enables the streaming of url.
UrlLoader:setStreaming(bool)
Parameters
bool: (boolean) streaming mode
Example
Streams an mp3 from the web
loader=UrlLoader.new()
loader:setStreaming(true) -- enable streaming mode
-- create our mp3 Buffer
loader.mp3=Buffer.new("buffer.mp3",true)
-- process stream data
loader:addEventListener(Event.PROGRESS,function (e)
loader.mp3:append(e.chunk)
if loader.mp3:size()>100000 and not loader.mp3.started then
Sound.new("|B|buffer.mp3"):play() -- play the buffer content by name
loader.mp3.started=true
end
if loader.mp3.started then
-- periodically trim already played data from buffer
loader.mp3:trim(loader.mp3:tell())
end
end)
loader:load("http://soundimage.org/wp-content/uploads/2017/08/Bubble-Gum-Puzzler.mp3")