UrlLoader:setStreaming

From GiderosMobile
Revision as of 13:05, 12 March 2023 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2020.2<br/> '''Class:''' UrlLoader<br/> === Description === Enables the streaming of url. <source lang="lua"> UrlLoader:setStream...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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")