Spout.SpoutReceiver.new
From GiderosMobile
Available since: Gideros 2019.5
Class: Spout
Description
Creates a new receiver. It is not connected to anything until bind() or receiveTexture() is called.
(SpoutReceiver) = SpoutReceiver.new()
Return values
Returns (SpoutReceiver) the new receiver object
Example
Receive from another application
require "spout"
local receiver = SpoutReceiver.new()
-- list the senders currently running on this machine
for _, s in ipairs(receiver:findSenders()) do
print(s.name, s.width, s.height)
end
-- connect to one of them and create a texture of the right size
local ok, name, w, h = receiver:bind("OBS-Studio", false)
local rt = RenderTarget.new(w, h, true, false, false, false, nil, false)
local texW, texH = w, h
local preview = Bitmap.new(rt)
stage:addChild(preview)
stage:addEventListener(Event.ENTER_FRAME, function(e)
-- keep the name Spout reports back, the sender may be renamed or replaced
local connected, actualName, aw, ah = receiver:receiveTexture(rt, name)
name = actualName or name
if connected and aw and ah and (aw ~= texW or ah ~= texH) then
-- the sender was resized: rebuild the receiving texture
texW, texH = aw, ah
rt = RenderTarget.new(texW, texH, true, false, false, false, nil, false)
preview:setTexture(rt)
end
end)