Skip to main content
Skip table of contents

Android/Apple Application

The source code of your react native Application  must include elements from the Insight React Native Plugin as well as the relevant required React/React Native components needed by your App in js/ts files, for example:

JS
import RNInsight from "@nagra/react-native-insight";
import React, { useEffect, useState } from "react";
import { View, Text, StyleSheet } from "react-native";
...

Initialize Insight session

A session is opened providing the JSON Insight configuration and user information to initialize API.

JS
RNInsight.initialize(insightConfig,userInfo)

Content Information

Set the content information of the current playback content using setVodContent if the content is VOD or setLiveContent if the content is LIVE.

JS
RNInsight.setVodContent(vodContent) // if content is VOD
RNInsight.setLiveContent(liveContent)// if content is LIVE

User Information

Set the user information to be sent to Insight using setUserInfo API. The user information needs to before calling the play API.

JS
RNInsight.setUserInfo(userInfo)

Start reporting

Start reporting that the user started playback of content using the play API. The content information needs to be set using RNInsight.setVodContent or RNInsight.setLiveContent APIs before calling the play API.

JS
RNInsight.play()

Playback events and Content information reporting APIs

Report playback playing event with playing API.

JS
RNInsight.playing()

Report the playback pause event with pause API.

JS
RNInsight.pause()

Report playback buffering event using buffering API.

JS
RNInsight.buffering()

Report that the user started seeking using seeking API.

JS
RNInsight.seeking()

Report the position of the seek using seekTo API.

JS
RNInsight.seekTo(position)

Report the current position of the playback using setPosition API.

JS
RNInsight.setPosition(position)

Report the language of the currently selected Audio track using setAudioLanguage API.

JS
RNInsight.setAudioLanguage(language)

Report the language of the currently selected Subtitle track using setSubtitleLanguage API.

JS
RNInsight.setSubtitleLanguage(language)

Report the available bitrates for the current playback content using setAvailableBitrates API.

JS
RNInsight.setAvailableBitrates(availableBitrates)

Report the playback content current selected bitrate using setBitrate API.

JS
RNInsight.setBitrate(bitrate)

Report the playback content quality using setContentQuality API.

JS
RNInsight.setContentQuality(contentQuality)

Report the number of frame drops to insight using setFrameDrops API.

JS
RNInsight.setFrameDrops(frameDrops)

Report offset from live for live content using setOffsetFromLive API.

JS
RNInsight.setOffsetFromLive(offset)

Report playback error event using addErrorEvent API.

JS
RNInsight.addErrorEvent(code, message)

.

Report any custom event using addNameEvent API.

JS
RNInsight.addNamedEvent(name, description)

Stop reporting

Report the playback stop for content using stop API.

JS
RNInsight.stop()

Terminate Insight session

A session is closed by terminate API.

JS
RNInsight.terminate()

Android-specific APIs

Report playback error event with type using addErrorEventWithType API.

JS
RNInsight.addErrorEventWithType(code, message,type)

Report HTTP request response to Insight using addNetworkEvent API.

JS
RNInsight.addNetworkEvent(NetworkEvent)

Get current Insight SDK version using getAgentVersion API.

JS
RNInsight.getAgentVersion(callback)

callback=(version)=>{
console.log("Insight version "+version)
}

Get content information reported to Insight using getContent API.

JS
RNInsight.getContent(callback)

callback=(content)=>{
console.log("Content information "+content)
}

Report the current playback content bitrate, resolution and codec information using setBitrateResolutionCodec API.

JS
RNInsight.setBitrateResolutionCodec(bitrate, resolution,codec)

Report playback content fps using setFramesPerSecond API.

JS
RNInsight.setFramesPerSecond(fps)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.