function collectEvents(localization, eventName, out) {
    const onEvent = (event) => {
      const fakeEvent = /** @type {!shaka.util.FakeEvent} */ (event);
      out.push(fakeEvent);
    };

    localization.addEventListener(eventName, onEvent);
  }
Listen to |localization| for specific events and save them in |out|.

@param {!shaka.ui.Localization} localization
@param {string} eventName
@param {!Array<!shaka.util.FakeEvent>} out