Skip to content

Instantly share code, notes, and snippets.

View acotilla91's full-sized avatar

Alejandro Cotilla acotilla91

View GitHub Profile
sub gifDecoderDidFinish(frames as Object, fps as Float)
m.animator.callFunc("start", frames, fps, m.posterGrid.getChild(m.focusedItem))
end sub
sub focusItem(item as Integer)
(...)
' Stop previous poster animation
m.animator.callFunc("finish")
end sub
sub init()
m.animator = createObject("roSGNode", "FrameAnimator")
(...)
end sub
sub init()
m.animator = CreateObject("roSGNode", "Timer")
m.animator.ObserveField("fire", "displayNextFrame")
m.animator.repeat = true
m.frames = []
m.frameIndex = -1
m.poster = invalid
end sub
<component name="FrameAnimator" extends="Node">
<interface>
<function name="start"/>
<function name="finish"/>
</interface>
<script type="text/brightscript" uri="pkg:/components/FrameAnimator.brs"/>
</component>
sub focusItem(item as Integer)
(...)
' Start decoder
m.decoder.callFunc("decodeGIF", getGIFUrl(item))
end sub
sub gifDecoderDidFinish(frames as Object, fps as Float)
?"frames "frames
end sub
sub init()
m.decoder = createObject("roSGNode", "GIFDecoder")
m.decoder.delegate = m.top
(...)
end sub
<component name="AppScene" extends="Scene">
<interface>
<!-- GIFDecoder callback -->
<function name="gifDecoderDidFinish"/>
</interface>
<script type="text/brightscript" uri="pkg:/components/AppScene.brs"/>
</component>
sub decodeGIF(gifPath as String)
m.top.functionName = "runDecoder"
m.gifPath = gifPath
m.gifName = CreateObject("roPath", m.gifPath).split().basename
m.top.control = "RUN"
end sub
sub runDecoder()
' Load the main GIF into memory.