// Set up mediaObject MediaObject mediaInfo = MediaHeartbeat.createMediaObject( Configuration.MEDIA_NAME, Configuration.MEDIA_ID, Configuration.MEDIA_LENGTH, MediaHeartbeat.StreamType.VOD ); HashMap videoMetadata = new HashMap(); videoMetadata.put(CUSTOM_KEY_1, CUSTOM_VAL_1); videoMetadata.put(CUSTOM_KEY_2, CUSTOM_VAL_2); // 1. Call trackSessionStart() when the user clicks Play or if autoplay is used, // i.e., there's an intent to start playback. _mediaHeartbeat.trackSessionStart(mediaInfo, videoMetadata); ...... ...... // Pre-roll MediaObject adBreakInfo = MediaHeartbeat.createAdBreakObject(ADBREAK_NAME, ADBREAK_POSITION, ADBREAK_START_TIME); MediaObject adInfo = MediaHeartbeat.createAdObject(AD_NAME, AD_ID, AD_POSITION, AD_LENGTH); // Context ad data HashMap adMetadata = new HashMap(); adMetadata.put(CUSTOM_KEY_1, CUSTOM_VAL_1); adMetadata.put(CUSTOM_KEY_2, CUSTOM_VAL_2); // 2. Track the MediaHeartbeat.Event.AdBreakStart event when the pre-roll pod starts // to play. Note that since this is a pre-roll, call must track the // "MediaHeartbeat.Event.AdBreakStart" event before you call trackPlay(). _mediaHeartbeat.trackEvent(MediaHeartbeat.Event.AdBreakStart, adBreakInfo, null); ....... ....... // 3. Track the MediaHeartbeat.Event.AdStart event when the pre-roll pod's ad starts // to play. Note that since this is a pre-roll, you must track the // "MediaHeartbeat.Event.AdStart" event before you call trackPlay(). _mediaHeartbeat.trackEvent(MediaHeartbeat.Event.AdStart, adInfo, adMetadata); ....... ....... // 4. Call trackPlay() when the playback actually starts, i.e., when the first frame // of the ad video is rendered on the screen. _mediaHeartbeat.trackPlay(); ....... ....... // 5. Track the MediaHeartbeat.Event.AdComplete event when the ad reaches the end, // i.e., when the ad completes and finishes playing. _mediaHeartbeat.trackEvent(MediaHeartbeat.Event.AdComplete, null, null); ....... ....... // 6. Track the MediaHeartbeat.Event.AdStart event when the pre-roll pod's second ad // starts to play. _mediaHeartbeat.trackEvent(MediaHeartbeat.Event.AdStart, adInfo, adMetadata); ....... ....... // 7. Track the MediaHeartbeat.Event.AdComplete event when the second ad reaches the // end, i.e., the second ad completes and finishes playing. _mediaHeartbeat.trackEvent(MediaHeartbeat.Event.AdComplete, null, null); ....... ....... // 8. Track the MediaHeartbeat.Event.AdBreakComplete event when all of the ads in the // pod finish playing. _mediaHeartbeat.trackEvent(MediaHeartbeat.Event.AdBreakComplete, null, null); ....... ....... // 9. Call trackComplete() when the playback reaches the end, i.e., when the video // completes and finishes playing. _mediaHeartbeat.trackComplete(); ........ ........ // 10. Call trackSessionEnd() when the playback session is over. This method must be // called even if the user does not watch the video to completion. _mediaHeartbeat.trackSessionEnd(); ........ ........

Welcome to M&F Television & Media Consulting website! We hope you will enjoy browsing through our website and find a lot of useful information here. We pay great attention to the quality of our consulting and training services. You can find detailed information about our services online or contact our customer service team for help.