mooball
    Preparing search index...

    Interface Replay

    interface Replay {
        read(
            uint8Array: Uint8Array,
            callbacks: CommonlyUsedCallbacks,
            options: ReplayReadOptions,
        ): AsyncReplayReader;
        readAll(uint8Array: Uint8Array): IReplayData;
        ReplayData: IReplayData;
        trim(
            replayData: IReplayData,
            params?: { beginFrameNo?: number; endFrameNo?: number },
        ): void;
        trimAsync(
            replayData: IReplayData,
            params?: { beginFrameNo?: number; endFrameNo?: number },
        ): Promise<void>;
        writeAll(replayData: IReplayData): Uint8Array;
    }
    Index

    Properties

    ReplayData: IReplayData

    The structure that holds all of the data inside a replay file.

    Methods

    • Creates and returns a non-blocking replay reader object.

      Parameters

      • uint8Array: Uint8Array

        Must be a Uint8Array containing the binary contents of a .hbr file. (Currently, only version 3 is supported.)

      • callbacks: CommonlyUsedCallbacks

        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.

      • options: ReplayReadOptions

        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.)

      Returns AsyncReplayReader

      An instance of the ReplayReader structure.

      Any internal Error will be thrown and should be caught using a try-catch block.

      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.

      Parameters

      • uint8Array: Uint8Array

        Must be a Uint8Array containing the binary contents of a .hbr file. (Currently, only version 3 is supported.)

      Returns IReplayData

      The new ReplayData structure that contains all of the information inside the binary replay data.

      try{
      var replayData = Replay.readAll(data);
      // ...
      // 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.

      Parameters

      • replayData: IReplayData

        The ReplayData structure that needs to be trimmed.

      • Optionalparams: { beginFrameNo?: number; endFrameNo?: number }

        An optional object that may contain beginFrameNo and endFrameNo integer keys.

      Returns void

      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.

      Parameters

      • replayData: IReplayData

        The ReplayData structure that needs to be trimmed.

      • Optionalparams: { beginFrameNo?: number; endFrameNo?: number }

        An optional object that may contain beginFrameNo and endFrameNo integer keys.

      Returns Promise<void>

      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.

      Parameters

      • replayData: IReplayData

        Must be a ReplayData structure.

      Returns Uint8Array

      The binary representation of the given ReplayData structure as a Uint8Array object.

      try{
      var data = Replay.readAll(replayData);
      // ...
      // Do something with the data.
      }
      catch(error){ // this is of type HBError
      console.log(error.toString()); // you have to use .toString() to convert it into a readable string
      }