Your Digital Media Has Never Looked So Good

 
philotas
Topic Author
Posts: 51
Joined: Tue Jun 14, 2016 4:03 am

call component function only possible via interface?

Thu Jul 07, 2016 10:38 am

When a component defines some function via <source> tag or inline. How can I call a function of the script in the context of the component?

Seems I can only do that by changing an interface fiel and register an onChange callback, correct?
 
philotas
Topic Author
Posts: 51
Joined: Tue Jun 14, 2016 4:03 am

Re: call component function only possible via interface?

Mon Jul 11, 2016 9:20 am

anybody?
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: call component function only possible via interface?

Mon Jul 11, 2016 10:11 am

I think you mean the <script> tag, and you should be able to call any of the functions in an included .brs file in your init, and while an observed field is, I think, necessary to initially call a function within an included file, I believe that called function should be able to call anything else within files included via the script tag. So if your onChange callback is a function named "DoSomething" -

function DoSomething()
     print "something"
     doSomethingElse()
end function

function DoSomethingElse() as integer
     print "something else"
     return -1
end function


Joel
 
philotas
Topic Author
Posts: 51
Joined: Tue Jun 14, 2016 4:03 am

Re: call component function only possible via interface?

Mon Jul 11, 2016 10:46 am

Hi Joel,
thanks for your answer, but that was not, what I meant:

Let's take this example script of a Vd

<Video
id="musicvideos"
width="1280"
height="720"
translation="[0,0]"
/>

<script type="text/brightscript" >
<![CDATA[

sub init()
m.top.setFocus(true)
setVideo()
end sub

function setVideo() as void
videoContent = createObject("RoSGNode", "ContentNode")
videoContent.url = "https://roku.s.cpl.delvenetworks.com/media/59021fabe3b645968e382ac726cd6c7b/60b4a471ffb74809beb2f7d5a15b3193/roku_ep_111_segment_1_final-cc_mix_033015-a7ec8a288c4bcec001c118181c668de321108861.m3u8"
videoContent.title = "Test Video"
videoContent.streamformat = "hls"

m.video = m.top.findNode("musicvideos")
m.video.content = videoContent
m.video.control = "play"
end function

]]>
</script>



My question is, whether I can call setVideo() from somewhere else then the init() or an onChange-Callback which changes, when the intefacefield changes.

So instead of this:
node.myInterfaceField = {url: ....} ' // trigger setVideo


do this:

node.setVideo({url: ....}) ' //


I am probably talking about having "interface functions".
at the moment it seams I have to have interface fields in order to trigger functions..

Who is online

Users browsing this forum: renojim and 3 guests