tonio-captions
A client for interaction with the Tonio service. It allows vendors to provide live captions.
Table of contents
Installation
Install with npm
npm install tonio-captions --save
Usage
The recommended way to use tonio-captions
is to create Tonio client
with base Tonio service url and initialize it before first usage.
tonio-captions
should be initialized only once:
const Tonio = ;//Provide base Tonio service url into constructor.const tonio = "https://api.tonio.com/v1/";//Tonio should be initialized only once before first usage.tonio;
You could check whether tonio-captions
is initialized or not
by using tonio.isInitialized
property:
console;
After finishing working with tonio-captions
is is recommended to free up
resources by using destroy method:
tonio;
Authentication
After creation of instance and initialization of tonio-captions
you have to pass authentication. You could sign in to Tonio using
your email and password via tonio.signIn
method:
tonio;
You could also subscribe to authentication state change
by using tonio.onAuthStateChange
method:
tonio;
If you dont want to use authentication state change callback
you could use tonio.isSignedIn
property to find out if user
is signed in or not:
console;
To sign out from Tonio just call tonio.signOut
method:
tonio;
Tonio API
When performance started you should call tonio.startPerformance
method with performance id. It updates performance with the actual start time:
tonio;
When performance ended you should call tonio.endPerformance
method with performance id. It updates performance with the actual end time:
tonio;
When during the performance an interval occures you should call
method tonio.startInterval
with performance id to start the interval:
tonio;
When started interval is ended you should call method
tonio.endInterval
with performance id to end the interval:
tonio;
When certain caption should be shown during the performance
you should call tonio.sendCaption
with performance id and
caption id to send Tonio the caption:
tonio;
Error Handling
If something is wrong during the Tonio methods invocation
TonioError
would be thrown. It has stack trace and
additional errors array properties:
tonio;
You could also convert TonioError
to JSON object:
tonio;
Logging
By default Tonio uses winston
library to log into file.
Default log level is error
and log directory is ./node_modules/tonio-captions/logs
.
Logs are rotated every week or by size, 20m
is maximum size of log file.
You could change log level to info
if you want to get more debug information:
toniologgerlevel = "info";
Or you could turn all logs off if you want to get rid of them:
toniologger = null;
Finally, you could replace the default logger with your own with tonio.logger
property. Keep in mind that your logger should implement following methods:
const functions = ;toniologger = functionslogger;toniologger;toniologger;toniologger;
Promises
tonio-captions depends on a native ES6 Promise implementation to be supported. If your environment doesn't support ES6 Promises, you can polyfill.