0

Brightscript - Do all events hit _ProcessEvent

Hi,

I know that for a plugin you create a message receiver (xxx_ProcessEvent). You also add logic to respond to certain events.

 

I wondered if all events go through this or only those you write code to specify? e.g. If I need to react to the roVideoEvent can I just look for this event type? or do I need to find the video player object and tell it to send it's events to the processevent function of my plugin?

 

For reference I need to output via UDP to a 3rd party application whenever the video changes. It's some eye tracking system and they need to know which video is playing in realtime. And no it's not Quividi so nothing exists to do this at the moment.

 

 

5 comments

  • 0
    Avatar
    Bright Scripters

    As far as I'm aware, you can capture events in a plugin from activities generated by the autorun, such as ones coming from roVideoPlayer.

    You should not modify the message port for objects that you have not created, as things may severely break.

    Putting that aside, you can get realtime playback report from a BrightAuthor Video List state, by checking "Send Zone message..."

    https://docs.brightsign.biz/download/attachments/983317/Media%20List.png?version=1&modificationDate=1478718385123&api=v2

     

    You would then capture the zone message in your plugin, and send over UDP. The disadvantage of this method, is that you need to be careful with other zone messages that you might use in your presentation, that are not being sent from the Video List.

  • 0
    Avatar
    Brandon

    Events pass through the queue until they're handled by something, so especially for things like UDP where there may be another receiver like BrightAuthor itself, you should be careful to only handle events that you need to.

    If you only want to "sniff" events and leave them in the queue for other processing, return false instead of true when you process it.

  • 0
    Avatar
    Andrew Pearce

    Thanks

    I managed to find a MEDIA_END event that comes through the event loop. 

    EventType = “MEDIA_END” but it seems that EventParameter is invalid e.g. not an array or string with the filename.

    I tried accessing the roVideoPlayer widget but there doesn't seem to be one created, I'm using a media list control.

    At the moment I'm just trying to find out the filename of the video playing but I'm finding it tough going.

    Below is my code. It runs but no filename is appearing.

    EventType = “MEDIA_END” means EventParameter is invalid

     

    Function shoppar_ProcessEvent(event As Object) as boolean

           retval = false

        print "shoppar_ProcessEvent - type of event is ";type(event)

     

           if type(event) = "roAssociativeArray" then

            if type(event["EventType"]) = "roString"

                 if (event["EventType"] = "SEND_PLUGIN_MESSAGE") then

                    if event["PluginName"] = "shoppar" then

                        pluginMessage$ = event["PluginMessage"]

                                      print "SEND_PLUGIN/EVENT_MESSAGE:";pluginMessage$

                        retval = ParsePluginMsg(pluginMessage$, m)

                    endif

                endif

            endif

                 

           else if type(event) = "roDatagramEvent" then

                  msg$ = event

                  parsepluginmsg(msg$, m)

                  '      if type(m.mycwidget) <> "roClockWidget" then m.findwidget()

                  '      if m.mycwidget <> invalid then m.mycwidget.hide()

     

           else if type(event) = "roVideoEvent" then

                         print "XXXXXXXXXXXXXXXXXXXXXXXXXXX - roVideoEvent Happened"

    print "A0"

                         if type(m.myvideowidget) <> "roVideoPlayer" then m.findvideowidget("roVideoPlayer")

    print "A1"   

                         if m.myvideowidget <> invalid then      

    print "A1.5"

                               videoinfo = m.myvideowidget.GetProperties()

    print "A2"

                               fname = info.Filename

    print "A3"

                               print "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY - " + fname

    print "A4"

                         end if

    print "A5"

                        

                         eventData = event.GetInt()

                        

                         if eventdata = 18 then 'end fade

    '                          myevent$ = "ef"

                               print "roVideoEvent, End Fade"

                        

    '                          pluginMessageCmd = CreateObject("roAssociativeArray")

    '                          pluginMessageCmd["EventType"] = "EVENT_PLUGIN_MESSAGE"

    '                           pluginMessageCmd["PluginName"] = "Shoppar"

    '                          pluginMessageCmd["PluginMessage"] = "testb!" + fname

    '                          m.msgPort.PostMessage(pluginMessageCmd)

                         end if

                 

           end if

     

    print "A6"

    print "shoppar_ProcessEvent - type of event is " + type(event)

    ' roAssociativeArray is ok but lacks the correct type

           if (type(event) <> "roVideoEvent") and (type(event) <> "roTimerEvent") and (type(event) <> "roUrlEvent") and (type(event) <> "roHttpEvent") then

                  if type(event["EventType"]) <> invalid then

                         print "A6.25"

                         if type(event["EventType"]) = "roString"

                               print "A6.5"

                               print "EventType: " + event["EventType"]

                               if (event["EventType"] = "MEDIA_END") then

                                      print "A7"

                                      filenameshowing = event["EventParameter"]

                                      print "A8"

                                      if (type(event["EventParameter"]) = "roString") then

                                             print "Filename = " + filenameshowing

                                      else

                                             print "NOT A STRING: " + type(event["EventParameter"])

                                      end if

                                      print "A9"

                               end if

                               if (event["EventType"] = "roAssociativeArray") then

                                      print "A10"

                                      filenameshowing = event[0]

                                      print "A11"

                                      if (type(filenameshowing) = "roString") then

                                             print "First 0 = " + filenameshowing

                                      else

                                             print "Not a string for 0"

                                      end if

                                     

                                      print "A12"

                               end if

                         end if

                  end if

           end if

           print "A10"

          

           return retval

     

    End Function

    Just to check there is no exception/error handling that I'm missing? As every time the bright script breaks I have to re-copy over the setup files again. Also if I miss a bracket or similar it just immediately crashes as there is no compiler to check for basic syntax errors, again there isn't anything I'm missing?

     

     

     

    I noticed a recovery URL but haven't set it up as I felt I needed to get a bit of code done rather than just work o my development environment. IS this easy/is tehre a simple guide?

     

  • 0
    Avatar
    Andrew Pearce

    I got it working in the end and have the details below in case anyone else has similar issues. 

     

    if (event["EventType"] = "SEND_ZONE_MESSAGE") then
      print("SEND_ZONE_MESSAGE")
      ' Get the filename in here
      filename = event["EventParameter"]
      if (type(filename) = "roString") then
        print("******************* VIDEO FILENAME *******************: [" + filename +"]")
      endif
    endif

  • 0
    Avatar
    Lyndon

    I"m assuming you set your media list to send a zone message with the file name.

    Depending on what you're doing, you can get the current file name via script other ways. For most files, the video name is the state name. I have a plugin that can pull that info out. The same plugin can be used to get a list of all videos, for example, that are current playing from dynamic playlist or mrss feeds. 

    If' you're using a video list or image list, then your way makes the most sense. 

     

Please sign in to leave a comment.