/** Procedural abstraction used to setup event handlers for the OnceUX plugin. */
 private void registerEventHandlers() {
   // Handle the case where the ad data URL has not been supplied to the plugin.
   EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter();
   eventEmitter.on(
       OnceUxEventType.NO_AD_DATA_URL,
       new EventListener() {
         @Override
         public void processEvent(Event event) {
           // Log the event and display a warning message (later)
           Log.e(TAG, event.getType());
           // TODO: throw up a stock Android warning widget.
         }
       });
 }
 private void initializeEvents(EventEmitter eventEmitter) {
   eventEmitter.on(
       EventType.ADD_ANALYTICS_BASE_PARAMS,
       new EventListener() {
         public void processEvent(Event event) {
           Map map =
               (Map)
                   event.properties.get(
                       com.brightcove.player.analytics.Analytics.Fields.BASE_PARAMS);
           if (map != null) {
             Analytics.this.baseParams.putAll(map);
           }
           Analytics.this.emitDidSetEvent();
         }
       });
   eventEmitter.on(
       EventType.SET_ANALYTICS_BASE_PARAMS,
       new EventListener() {
         public void processEvent(Event event) {
           Map map =
               (Map)
                   event.properties.get(
                       com.brightcove.player.analytics.Analytics.Fields.BASE_PARAMS);
           if (map != null) {
             Analytics.this.baseParams.clear();
             Analytics.this.baseParams.putAll(map);
           }
           Analytics.this.emitDidSetEvent();
         }
       });
   eventEmitter.on(
       EventType.DID_SET_VIDEO,
       new EventListener() {
         public void processEvent(Event event) {
           if (Analytics.this.endTime - Analytics.this.startTime > 0) {
             Analytics.this.sendVideoEngagementRequest(
                 event, Analytics.this.startTime, Analytics.this.endTime);
           }
           Analytics.this.sendVideoAnalyticsRequest(event, "video_impression", null);
           Analytics.this.startTime = Analytics.this.endTime = 0;
           Analytics.this.hasStarted = false;
         }
       });
   eventEmitter.on(
       EventType.DID_SEEK_TO,
       new EventListener() {
         public void processEvent(Event event) {
           int integerProperty = event.getIntegerProperty(Event.SEEK_POSITION);
           if (integerProperty > 0 && integerProperty - Analytics.this.endTime > 1000) {
             Analytics.this.sendVideoEngagementRequest(
                 event, Analytics.this.startTime, Analytics.this.endTime);
             Analytics.this.startTime = Analytics.this.endTime = integerProperty;
           }
         }
       });
   eventEmitter.on(
       EventType.PROGRESS,
       new EventListener() {
         public void processEvent(Event event) {
           Video video = (Video) event.properties.get(Event.VIDEO);
           int integerProperty = event.getIntegerProperty(Event.PLAYHEAD_POSITION);
           if (integerProperty < 0) {
             return;
           }
           if (Math.abs(Analytics.this.endTime - integerProperty) > 5000) {
             Analytics.this.sendVideoEngagementRequest(
                 event, Analytics.this.startTime, Analytics.this.endTime);
             Analytics.this.startTime = Analytics.this.endTime = integerProperty;
           } else {
             Analytics.this.endTime = integerProperty;
             if (!(Analytics.this.hasStarted || video == null || Analytics.this.endTime == 0)) {
               Analytics.this.sendVideoAnalyticsRequest(event, "video_view", null);
               Analytics.this.hasStarted = true;
             }
             if (Analytics.this.endTime - Analytics.this.startTime >= 10000) {
               Analytics.this.sendVideoEngagementRequest(
                   event, Analytics.this.startTime, Analytics.this.endTime);
               Analytics.this.startTime = Analytics.this.endTime;
             }
           }
         }
       });
   eventEmitter.on(
       EventType.COMPLETED,
       new EventListener() {
         public void processEvent(Event event) {
           int integerProperty = event.getIntegerProperty(Event.PLAYHEAD_POSITION);
           if (integerProperty >= 0) {
             Analytics.this.endTime = integerProperty;
             Analytics.this.sendVideoEngagementRequest(
                 event, Analytics.this.startTime, Analytics.this.endTime);
             Analytics.this.startTime = Analytics.this.endTime;
             Analytics.this.sendVideoAnalyticsRequest(event, "video_complete", null);
           }
         }
       });
 }