Skip to content

Webplayer

Overview

The Netzyn WebPlayer provides for streaming a cloud app into a web page via either a browser app or a WebView embedded in another app. This is in lieu of using a platform native Netzyn Player app or library.

The Netzyn WebPlayer consists of a single javascript file, which is about 100KB in size. To use on a HTML page, include the javascript file, create a /div and initiate the single WebPlayer API. The WebPlayer will communicate to the Netzyn servers which will launch the desired cloud app. The cloud app will stream into the supplied div. The WebPlayer takes care of all interaction with the user, i.e. touch, mouse, keyboard, audio, etc.

image

API

The WebPlayer API consists of

    NzPlayerWebBrowser(alt_name, webplayer_div, app, orientation, auth_id, user_id, future, playerStatus);
        alt_name - leave blank
        webplayer_div - the div of the webplayer
        app - cloud app id
        orientation - leave blank, not used currently
        auth_id - authentication string provided by Netzyn
        user_id - ID of current user
        future - leave blank ( "" or '' )
        playerStatus - callback function that takes a status param; may be null
                callback function signature takes 2 params, integer, and status specific data
                example callback signature :
                    function myCallbackFunction(statusID, statusData)

    NzPlayerWebBrowserSendData(oidApp, oid1, param, data )
        Send app specific data to cloud app
            oidApp - NOT USED [set to '' or null]
            oid1   - NOT USED [set to '' or null]
            param  - integer value associated with data
            data   - bases64 encoded data
The div (webplayer_div parm) must be the correct size before calling NzPlayerWebBrowser(). This is because most Android apps can not be resized once they are run.

API Callbacks

WebPlayer API callbacks are invoked if the playerStatus param passed to NzPlayerWebBrowser API is a valid function. The playerStatus has a signature of (statusID, statusData)

StatusID statusData Description
NZWEBPLAYER_STATUS_UNSUPPORTED_BROWSER null User's browser is not supported
NZWEBPLAYER_STATUS_INVALID_TOKEN null Unable to authenticate auth_id passed to NzPlayerWebBrowser
NZWEBPLAYER_STATUS_INVALID_DIV null HTML div webplayer_div, passed to NzPlayerWebBrowser is not a valid element
NZWEBPLAYER_STATUS_NO_SERVER null Unable to establish connection with NZ server
NZWEBPLAYER_STATUS_NO_APP null Unable to launch app on server
NZWEBPLAYER_STATUS_WEBSOCKET_CLOSED null Websocket has closed
NZWEBPLAYER_STATUS_VERSION_MISMATCH null Browser webplayer's version not compatible with server
NZWEBPLAYER_STATUS_REST_ERROR null REST API error, app not launched
NZWEBPLAYER_STATUS_EXCESS_PACKET_LOSS null Significant network packet loss
NZWEBPLAYER_STATUS_RECVDATA JSON data Called when app specific data has been sent by cloud App

Github Repository

The Netzyn WebPlayer repo provides sample code that can be used as a starting point for the actual implementations.

https://github.com/Netzyn/webplayer

In the repo are four directories: page, timer, launcher and ttg. Page and timer are web pages that display the cloud app either as the entire page (page) or portion of the page (timer). Launcher and TTG (Try the Games) are examples that use play and/or timer. To get started go to the repo's Releases page and download/untar the latest version and place on a web server. For the example launch lines below, the repo has been placed in a webplayer directory on the web server. Before you can use any of these, you need to obtain an auth id from Netzyn and place the auth_id in timer.html and page.html files. For most development timer.html is the file to copy and use as the basis for the webpage that displays the cloud app. The ttg.html file contains a table of valid app ids (url field) to test with. This is used for the app parm in timer/page and the app field in NZPlayerWebBrowser() API.

page/

A page that displays the cloud app covering the full page. It is invoked with a parm with the app name. Example: https://<server_url>/webplayer/page/page.html?app=draw

timer/

A page that displays the cloud app plus a tool bar. The toolbar contains a timer along with an install button. It is invoked with parms for the app name and a URL to launch when the Install button is clicked.

Example: https://<server_url>/webplayer/timer/timer.html?app=draw&install=<android_app_store_url>&install_ios=<ios_app_store_url

ttg/

A full featured example that uses timer above.

Example: https://<server_url>/webplayer/ttg/ttg.html

launcher/

A simple example that uses both page and timer above.

Example: https://<server_url>/webplayer/launcher/launcher.html