L'agent multimédia New Relic pour les appareils Roku capture les événements qui se produisent pendant la lecture de contenu vidéo. Ce document fournit un aperçu des événements qui peuvent être capturés et comment les activer dans votre application Roku.
Pour activer la capture automatique des événements, procédez comme suit :
Dans votre fichier BrightScript principal (par exemple, Main.brs), appelez la fonction NewRelic et stockez l'objet renvoyé.
Appelez nrAppStarted pour log l’événement de démarrage de l’application.
(Facultatif) Utilisez NewRelicSystemStart et NewRelicVideoStart pour commencer à capturer le système et l'événement vidéo.
Dans la boucle d'attente principale, appelez nrProcessMessage pour gérer l'événement système.
Exemple
Vous trouverez ci-dessous un exemple de base d’intégration de l’agent New Relic dans une application Roku :
Main.brs
sub Main(aa as Object)        screen = CreateObject("roSGScreen")        m.port = CreateObject("roMessagePort")        screen.setMessagePort(m.port)
        'Create the main scene that contains a video player        scene = screen.CreateScene("VideoScene")        screen.show()                    'Init New Relic Agent        m.nr = NewRelic(“ACCOUNT ID“, “API KEY“)                    'Send APP_STARTED event        nrAppStarted(m.nr, aa)                    'Pass NewRelicAgent object to the main scene        scene.setField("nr", m.nr)                    'Activate system tracking        m.syslog = NewRelicSystemStart(m.port)                while (true)            msg = wait(0, m.port)            if nrProcessMessage(m.nr, msg) = false                'It is not a system message captured by New Relic Agent                if type(msg) = "roPosterScreenEvent"                    if msg.isScreenClosed()                        exit while                    end if                end if            end if        end while    end subVideoScene.xml
<?xml version="1.0" encoding="utf-8" ?>    <component name="VideoScene" extends="Scene">             <interface>                    <!-- Field used to pass the NewRelicAgent object to the scene -->                    <field id="nr" type="node" onChange="nrRefUpdated" />            </interface>                    <children>                    <Video                            id="myVideo"                            translation="[0,0]"                    />            </children>                <!-- New Relic Agent Interface -->            <script type="text/brightscript" uri="pkg:/source/NewRelicAgent.brs"/>                <script type="text/brightscript" uri="pkg:/components/VideoScene.brs"/>    </component>VideoScene.brs [#videoscene.brs]
sub init()    m.top.setFocus(true)    setupVideoPlayer()end sub
function nrRefUpdated()    m.nr = m.top.nr        'Activate video tracking    NewRelicVideoStart(m.nr, m.video)end function
function setupVideoPlayer()    videoUrl = "http://..."    videoContent = createObject("RoSGNode", "ContentNode")    videoContent.url = videoUrl    videoContent.title = "Any Video"    m.video = m.top.findNode("myVideo")    m.video.content = videoContent    m.video.control = "play"end function