Creates and returns a non-blocking replay reader object.
Must be a Uint8Array containing the binary contents of a .hbr file. (Currently, only version 3 is supported.)
An object that may have all callbacks defined in sections 2, 3.1 and 4 of our event callbacks documentation. In addition, it is possible to use a render callback that has the same signature as defined in section 3 of our Renderer documentation.
An object that may contain the following keys:
requestAnimationFrame: Override function for requestAnimationFrame. (null = use library's default requestAnimationFrame.)cancelAnimationFrame: Override function for cancelAnimationFrame. (null = use library's default cancelAnimationFrame.)An instance of the ReplayReader structure.
try{
var replayReader = Replay.read(data, {
onPlayerChat: (id, message) => {
console.log(id + " : " + message);
},
onPlayerTeamChange: (id, teamId, byId) => {
console.log(id + " was moved to " + teamId + " by " + byId);
}
});
replayReader.onEnd = ()=>{ // the end of replay data is reached.
replayReader.destroy(); // release the resources
};
replayReader.setSpeed(1); // start playing
}
catch(error){ // this is of type HBError
console.log(error.toString()); // you have to use .toString() to convert it into a readable string
}
Reads all of the given binary replay data into a new ReplayData structure and returns it.
Must be a Uint8Array containing the binary contents of a .hbr file. (Currently, only version 3 is supported.)
The new ReplayData structure that contains all of the information inside the binary replay data.
Trims the given ReplayData between given frame numbers beginFrameNo and endFrameNo, both of which can be omitted and are
inclusive. If omitted, beginFrameNo defaults to 0 and endFrameNo defaults to replayData.totalFrames-1.
The ReplayData structure that needs to be trimmed.
Optionalparams: { beginFrameNo?: number; endFrameNo?: number }An optional object that may contain beginFrameNo and endFrameNo integer keys.
void.
try{
var replayData = Replay.readAll(data);
Replay.trim(replayData, {beginFrameNo: 1000, endFrameNo: 5000});
// Now the replayData only contains the frames between 1000 and 5000.
// ...
// Do something with the replay data.
}
catch(error){ // this is of type HBError
console.log(error.toString()); // you have to use .toString() to convert it into a readable string
}
Trims the given ReplayData between given frame numbers beginFrameNo and endFrameNo, both of which can be omitted and are
inclusive. If omitted, beginFrameNo defaults to 0 and endFrameNo defaults to replayData.totalFrames-1.
The ReplayData structure that needs to be trimmed.
Optionalparams: { beginFrameNo?: number; endFrameNo?: number }An optional object that may contain beginFrameNo and endFrameNo integer keys.
A Promise that is resolved when the trimming job is finished.
try{
var replayData = Replay.readAll(data);
Replay.trimAsync(replayData, {beginFrameNo: 1000, endFrameNo: 5000}).then(()=>{
// Now the replayData only contains the frames between 1000 and 5000.
// ...
// Do something with the replay data.
});
}
catch(error){ // this is of type HBError
console.log(error.toString()); // you have to use .toString() to convert it into a readable string
}
Converts all information inside the given ReplayData structure into a Uint8Array and returns it.
Must be a ReplayData structure.
The binary representation of the given ReplayData structure as a Uint8Array object.
The structure that holds all of the data inside a replay file.