UrlLoader:setStreaming: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2020.2<br/> '''Class:''' UrlLoader<br/> === Description === Enables the streaming of url. <source lang="lua"> UrlLoader:setStream..."
 
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
=== Description ===
=== Description ===
Enables the streaming of url.
Enables the streaming of url.
<source lang="lua">
<syntaxhighlight lang="lua">
UrlLoader:setStreaming(bool)
UrlLoader:setStreaming(bool)
</source>
</syntaxhighlight>


=== Parameters ===
=== Parameters ===
Line 14: Line 14:
=== Example ===
=== Example ===
'''Streams an mp3 from the web'''
'''Streams an mp3 from the web'''
<source lang="lua">
<syntaxhighlight lang="lua">
loader=UrlLoader.new()
loader=UrlLoader.new()
loader:setStreaming(true) -- enable streaming mode
loader:setStreaming(true) -- enable streaming mode
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")
</source>
</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")