Update SDKdebug + player
** Player - Add new callbacks : onUserActive / onUserInactive / onSessionStopped ** SDK Debug - Add ws:// il ws URL. ** Update readme
This commit is contained in:
Родитель
b149af8a7d
Коммит
1aa0da0c8f
12
README.md
12
README.md
|
@ -38,6 +38,18 @@ Instanciate the player for a given app.
|
||||||
Bind a callback that will be called when the player is ready.
|
Bind a callback that will be called when the player is ready.
|
||||||
- `callback: Function`: Your own code to do what you want when it's ready (ex: call start()).
|
- `callback: Function`: Your own code to do what you want when it's ready (ex: call start()).
|
||||||
|
|
||||||
|
#### onUserActive(callback)
|
||||||
|
Bind a callback that will be called when the user is active on your session (only fired when a session is running).
|
||||||
|
- `callback: Function`: Implement your code.
|
||||||
|
|
||||||
|
#### onUserInactive(callback)
|
||||||
|
Bind a callback that will be called when the user is inactive on your session (only fired when a session is running).
|
||||||
|
- `callback: Function`: Implement your code.
|
||||||
|
|
||||||
|
#### onSessionStopped(callback)
|
||||||
|
Bind a callback that will be called when the session is stopped (ex: stopped for inactivity)
|
||||||
|
- `callback: Function`: Implement your code.
|
||||||
|
|
||||||
### Methods to create your own interface
|
### Methods to create your own interface
|
||||||
Those methods permit you to create your own interface.
|
Those methods permit you to create your own interface.
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,10 @@ const _eventNames = {
|
||||||
RESTART_STREAM: "restartStream",
|
RESTART_STREAM: "restartStream",
|
||||||
ON_SDK_MESSAGE: "onSDKMessage",
|
ON_SDK_MESSAGE: "onSDKMessage",
|
||||||
SEND_SDK_MESSAGE: "sendSDKMessage",
|
SEND_SDK_MESSAGE: "sendSDKMessage",
|
||||||
SET_LOCATION: "setLocation"
|
SET_LOCATION: "setLocation",
|
||||||
|
ON_USER_ACTIVE: "onUserActive",
|
||||||
|
ON_USER_INACTIVE: "onUserInactive",
|
||||||
|
ON_SESSION_STOPPED: "onSessionStopped"
|
||||||
};
|
};
|
||||||
|
|
||||||
const _qualityValues = {
|
const _qualityValues = {
|
||||||
|
@ -161,6 +164,21 @@ module.exports = class Player {
|
||||||
this._onSDKMessageCallback(e.data.value);
|
this._onSDKMessageCallback(e.data.value);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
case _eventNames.ON_USER_ACTIVE:
|
||||||
|
if (this._onUserActiveCallback) {
|
||||||
|
this._onUserActiveCallback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case _eventNames.ON_USER_INACTIVE:
|
||||||
|
if (this._onUserInactiveCallback) {
|
||||||
|
this._onUserInactiveCallback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case _eventNames.ON_SESSION_STOPPED:
|
||||||
|
if (this._onSessionStoppedCallback) {
|
||||||
|
this._onSessionStoppedCallback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
case _eventNames.ERROR:
|
case _eventNames.ERROR:
|
||||||
this._displayErrorMessage(e.data.value);
|
this._displayErrorMessage(e.data.value);
|
||||||
return;
|
return;
|
||||||
|
@ -281,6 +299,18 @@ module.exports = class Player {
|
||||||
this._onSDKMessageCallback = onSDKMessageCallback;
|
this._onSDKMessageCallback = onSDKMessageCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUserActive(onUserActiveCallback) {
|
||||||
|
this._onUserActiveCallback = onUserActiveCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
onUserInactive(onUserInactiveCallback) {
|
||||||
|
this._onUserInactiveCallback = onUserInactiveCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSessionStopped(onSessionStoppedCallback) {
|
||||||
|
this._onSessionStoppedCallback = onSessionStoppedCallback;
|
||||||
|
}
|
||||||
|
|
||||||
sendSDKMessage(data) {
|
sendSDKMessage(data) {
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
return; // Not loaded.
|
return; // Not loaded.
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = class SDKDebug {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init WS connection.
|
// Init WS connection.
|
||||||
this.ws = new WebSocket(localServerAddress);
|
this.ws = new WebSocket("ws://" + localServerAddress);
|
||||||
this.ws.binaryType = 'arraybuffer';
|
this.ws.binaryType = 'arraybuffer';
|
||||||
this.ws.onerror = (event) => {this._wsOnError(event)};
|
this.ws.onerror = (event) => {this._wsOnError(event)};
|
||||||
this.ws.onclose = (event) => {this._wsOnClose(event);}
|
this.ws.onclose = (event) => {this._wsOnClose(event);}
|
||||||
|
@ -53,7 +53,6 @@ module.exports = class SDKDebug {
|
||||||
return; // Not loaded.
|
return; // Not loaded.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.ws.send(JSON.stringify(data),this._wsOnSendError);
|
this.ws.send(JSON.stringify(data),this._wsOnSendError);
|
||||||
}
|
}
|
||||||
}
|
}
|
Загрузка…
Ссылка в новой задаче