Adam16 / furioos-sdk-js

Furioos SDK for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Furioos SDK

Requirements

  • A Furioos Account on www.furioos.com available from the Business plan.
  • Then choose the application you want to use with the SDK and create a SDK link.

Table of contents

Installation

npm install --save furioos-sdk

API

constructor(sdkShareLinkID, containerDivId, options)

Instanciate the player for a given application.

Property Type Description optional DefaultValue
sdkShareLinkID String Furioos SDK Link ID of the application you want to share. false null
containerDivId String The ID of the HTML container div that will host the render. false null
options Object The options to setup the player are these following : true {}
options:
Property Type Description optional DefaultValue
whiteLabel Boolean Remove all Furioos' Logo true false
hideToolbar Boolean Hide the toolbar to create your own true false
hideTitle Boolean Hide the title bar to create your own true false
hidePlayButton Boolean Hide the play button true false
overridedURL Boolean Override the url of the server you want to communicate with true "https://portal.furioos.com"
debugAppMode Boolean Active local debug of your application. See Debug localy the SDK communication tunnel for more detail true false
wsServerAddress String Set up the ip address of your websocket server. See Debug localy the SDK communication tunnel for more detail true "127.0.0.1"

Example

import { Player } from 'furioos-sdk';

const options = {
  whiteLabel: true,
  hideToolbar: false,
  hideTitle: true,
  hidePlayButton: false,
};

const player = new Player("123.456", "containerDivId", options);

Properties

quality: String

Get the current setted quality. Possible values : AUTO / LOW / MEDIUM / HIGH / ULTRA

Events

onLoad(function() {})

Bind a callback that will be called when the player is ready.

Example

player.onLoad(function() {
  // Here you know when the player is ready.
  player.start();
})
onAppInstallProgress(function(data) {})

Bind a callback that will be called during your application installation. You'll receive the progress of the installation.

data:

Property Type Description Value
status String The current installation step "COPYING" or "DECOMPRESSING"
progress Number The progress value between 0 and 1

Example

player.onAppInstallProgress(function(data) {
  // Implement your own code.
  console.log(data.status + " the application : " + Math.round(data.progress*100) + "%");
})
onAppInstallSuccess(function() {})

Bind a callback that will be called when your application installation has succeed.

Example

player.onAppInstallSuccess(function() {
  // Implement your own code.
  console.log("My application is fully installed");
})
onAppInstallFail(function() {})

Bind a callback that will be called when your application installation has failed.

Example

player.onAppInstallFail(function() {
  // Implement your own code.
  console.log("Installation has failed");
})
onAppStart(function() {})

Bind a callback that will be called when your application starts.

Example

player.onAppStart(function() {
  // Implement your own code.
  console.log("Application started");
})
onStreamStart(function() {})

Bind a callback that will be called when the stream starts.

Example

player.onStreamStart(function() {
  // Implement your own code.
  console.log("Stream started");
})
onUserActive(function() {})

Bind a callback that will be called when the user is **active** on your session (only fired when a session is running).

Example

player.onUserActive(function() {
  // Implement your own code.
  console.log("My user is active");
})
onUserInactive(function() {})

Bind a callback that will be called when the user is **inactive** on your session (only fired when a session is running).

Example

player.onUserInactive(function() {
  // Implement your own code.
  console.log("My user is inactive");
})
onSessionStopped(function() {})

Bind a callback that will be called when the session is stopped (ex: stopped for inactivity).

Example

player.onSessionStopped(function() {
  // Implement your own code.
  console.log("The session has been stopped");
})
onStats(function(stats) {})

Bind a callback that will be called frequently during a running session with all stats.

stats:

Property Type Description DefaultValue
appHeight Number Height of the application screen on VM 0
appWidth Number Width of the application screen on VM 0
dataLatency Number Round trip network latency 0
dataMethod String events/data transmission method (value: "datachannel" or "ws") "datachannel"
packetsLost Number Percent of lost packets (value: 0 to 1) 0
serverCpuUsage Number Server CPU usage 0
serverEncodingMs Number Server encoding time (milliseconds) 0
serverFramerate Number Server framerate 0
serverGpuMemTotal Number Total GPU RAM available on server (byte) 0
serverGpuMemUsed Number Current GPU RAM used on server (byte) 0
serverGpuUsage Number Server GPU usage percent 0
serverGrabbingMs Number Server grabbing time (milliseconds) 0
serverRamTotal Number Total RAM available on serve (byte) 0
serverRamUsed Number Current RAM used on server (byte) 0
streamingEngine String Current streaming engine used (value: "Furioos" or "RenderStreaming") "Furioos"
userActive Boolean Define if the user is consider as active by the Furioos player 0
videoBitrate Number Received video bitrate (kbps) 0
videoFramerate Number Received video framerate 0
videoHeight Number Heigh of the received video 0
videoWidth Number Width of the received video 0
videoLatency Number Total video latency (round trip network latency + decoding time) 0

Example

player.onStats(function(stats) {
  // Implement your own code.
  console.log("Stats received: ", stats);
})

Methods

setUserActive()

This function help you to keep the session open if your user does not interact with the interface.
Calling this function will fire onUserActive.
⚠️ If you always call it without checking if the user is really here the session will never ended untill the user close his window.

setThumbnailUrl(url)

Change the thumbnail of your app.

Property Type Description DefaultValue
url String A public url of the thumbnail you want to set null
getServerAvailability(function(data) {}, function(error) {})

Call this function to get an estimated time to get a session on Furioos.

data:

Property Type Description DefaultValue
assignTime Number Estimated time (minutes) to be assigned to a server 0
launchTime Number Estimated time (minutes) for your app to be ready (copied, extracted and launched) 0
availableMachines Number Number of ready VM waiting for a session 0
*maximumMachines Number Maximum machines setted on your campaign 0
*usedMachines Number Number of current used machines in your pool 0
*creatingMachines Number Number of creating machines (creating machine in the cloud) 0
*installingMachines Number Number of installing machine (installing your application on it) 0

* Those values are only available for an application running on a pre-allocated campaign.

Example:

  player.getServerAvailability(function(data) {
    console.log("Time to assign a server: ", data.assignTime);
    console.log("Time to copy, extract and launch your application: ", data.launchTime);
    console.log("Number of machines ready for a session: ", data.availableMachines);
    console.log("Total time to get session ready: ", data.assignTime + data.launchTime);
  }, function(error) {
    // Treat the error.
  });
getServerMetadata(function(metadata) {}, function(error) {})

Call this function to get unique VM informations. This function return metadata only when a session is running.

metadata:

Property Type Description DefaultValue
publicIP String The VM public IP. ""
name String A unique name to identify a VM. ""

Example:

  player.getServerAvailability(function(metadata) {
    console.log("Public VM IP: ", metadata.publicIP);
    console.log("VM unique name: ", metadata.name);
  }, function(error) {
    // Treat the error.
  });
start(location)

Start a new session.

Property Type Description DefaultValue Optional
location String The VM public IP. "" true

Example:

  player.start(Player.regions.EUW);

stop()

Stop the session.

maximize()

Enable Full screen mode.

minimize()

Disable Full screen mode.

setQuality(quality)

Set the quality of the stream.

Property Type Description DefaultValue Optional
quality QualityValue Use one of the static value Player.qualityValues.AUTO / Player.qualityValues.LOW / Player.qualityValues.MEDIUM / Player.qualityValues.HIGH / Player.qualityValues.ULTRA Furioos App Quality false

Example:

  player.setQuality(Player.qualityValues.ULTRA);

restartStream()

Restart the streaming.

Communicate with your application

Go deeper with your UI by creating your own data interpretation.
Those methods let you send/receive JSON data between your application and the HTML page where you have implemented the JS SDK.

Requirements

onSDKMessage(function(data) {})

Bind a callback to receive messages from your application.

Property Type Description DefaultValue Optional
data Object The JSON that you send from your application. null false

Example:

  player.onSDKMessage(function(data) {
    console.log("Message received from my application: ", data);
  });
sendSDKMessage(data)

Send data to your own application by using the Furioos SDK.

Property Type Description DefaultValue Optional
data Object The data you want to send to your app formated in JSON. null false

Example:

  player.sendSDKMessage({ "test": "test" }); 

Debug localy the SDK communication tunnel

⚠️ This feature cannot work without running the following example: furioos-sdk-js-example

With this project, you'll be able to communicate localy with your application through port 8081.

⚠️ There will be no stream.

This feature open a direct tunnel between your js and your application running localy.
Only sendSDKMessage and onSDKMessage can be used here to test the communication.

How does it work ?

You just need to enable the debugAppMode.

import { Player } from 'furioos-sdk';

const options = {
  whiteLabel: true,
  hideToolbar: false,
  hideTitle: true,
  hidePlayButton: false,
  debugAppMode: true, // This enable the local debug mode.
};

const player = new Player("123.456", "containerDivId", options);

⚠️ Common Errors

  • Failed to execute 'postMessage' on 'DOMWindow': The target origin (http://....) provided does not match the recipient window's origin ('http://...')

    This error means that you do not have the correct website URL setted on your SDK link on Furioos.
    If the url your are testing the player implementation is http://localhost:8080, you must have this url as website url of your SDK link on Furioos (by creating or editing one).

About

Furioos SDK for JavaScript


Languages

Language:JavaScript 100.0%