Skip to content

Initializing the Components

The FlussonicWatcherView component

To make FlussonicWatcherView start playing video, you need to call two methods:

  • one of the initialize() methods
  • setUrl(@NonNull String url).

The order of calling of these methods is not important.

Certain parameters must be passed to initialize(). Depending on how you use FlussonicWatcherView, the following variants are possible:

  • Activity
  • Fragment
  • Activity and the boolen sign that indicates that you use this SDK in React Native (this method is used in the React Native module of Flussonic Watcher SDK).

In Java code you need to call the setter setUrl(). In React Native you need to specify the url parameter when initializing the component in the layout.

The FlussonicThumbnailView component

In order for FlussonicThumbnailView to start loading a video frame, you need to call the method

setUrl(@NonNull String url)

or

show(@NonNull Camera camera, @Nullable Date date).

In the first case, the parameters used for loading an MP4 frame will be generated using the passed URL string (see later on this page).

In the second case, the component will first try to get the streamer connection parameters, and then generate an MP4-frame loading parameters by using the received streamer parameters.

The URL format

The passed URL must be in the following notation:

<protocol>://<token>@<server>:<port>/<stream>?<query>

Here:

  • <protocol>http or https
  • <token> — the token obtained through the login call (the part <token>@ is allowed to be missing).
  • <server> — the name of the Watcher server to which you need to send the call cameras.
  • <port> — the port on the server (the part :<port> is allowed to be missing)
  • <stream> — the camera name
  • <query> — query string (?<query> is allowed to be missing). When the URL is parsed out, in <query> the substring from=<number> is sought for, and the <number> is understood as startPosition (see the method setStartPosition).

In Java code the standard URL parser is used, and also additional checks, so you can pass many different variants of the URL — the parameters that are obtained after parsing will be the same for many variants of URL notation.

Example

Suppose the following URL was passsed:

http://ZrYTXYC_m_msfRY4cZChbcvRj80@demo-watcher.flussonic.com/camera.32-84a1f604d5

The SDK performs the call to Watcher

http://demo-watcher.flussonic.com/vsaas/api/v2/cameras?search=camera.32-84a1f604d5

and obtains the parameters for connecting to a streamer.

Then, in FlussonicWatcherView you make the following calls to recording_status:

  • to get the beginning and ending of the DVR recording:

https://demo-watcher.flussonic.com/camera.32-84a1f604d5/recording_status.json?token=WyJhODkxIiwzMl0.DjDejw.NiqeL_p4z02NGjFuXwpBi6gfcCw

  • to get recorded ranges (intervals) of the DVR recording:

https://demo-watcher.flussonic.com/camera.32-84a1f604d5/recording_status.json?request=motion_log,ranges&token=WyJhODkxIiwzMl0.DjDejw.NiqeL_p4z02NGjFuXwpBi6gfcCw&from=1531923717&to=1531923737