Difference between revisions of "UrlLoader:setStreaming"
(Created page with "__NOTOC__ '''Available since:''' Gideros 2020.2<br/> '''Class:''' UrlLoader<br/> === Description === Enables the streaming of url. <source lang="lua"> UrlLoader:setStream...") |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
Line 5: | Line 5: | ||
=== Description === | === Description === | ||
Enables the streaming of url. | Enables the streaming of url. | ||
− | < | + | <syntaxhighlight lang="lua"> |
UrlLoader:setStreaming(bool) | UrlLoader:setStreaming(bool) | ||
</source> | </source> | ||
Line 14: | Line 14: | ||
=== Example === | === Example === | ||
'''Streams an mp3 from the web''' | '''Streams an mp3 from the web''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
loader=UrlLoader.new() | loader=UrlLoader.new() | ||
loader:setStreaming(true) -- enable streaming mode | loader:setStreaming(true) -- enable streaming mode |
Latest revision as of 14:32, 13 July 2023
Available since: Gideros 2020.2
Class: UrlLoader
Description
Enables the streaming of url. <syntaxhighlight lang="lua"> UrlLoader:setStreaming(bool) </source>
Parameters
bool: (boolean) streaming mode
Example
Streams an mp3 from the web <syntaxhighlight lang="lua"> 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") </source>