The Media SDK automatically tracks how long the media playback is in one of the following inactive states:
If a media tracking session remains in an inactive state for longer than 30 minutes, the session will automatically be closed. If the user resumes after a previously inactive video tracking session (trackPlay
), Media Heartbeat automatically creates a new video session using the previously used video information and metadata, and sends a resume heartbeat event. For more information, see Audio and video parameters.
The Media SDK will only automatically resume sessions if the application was not closed. If the application stores user data and has the capability to resume a previously closed media, it is possible to manually trigger a resume event. When starting the video tracking session, set the optional Video Resumed property.
// Set MediaHeartbeat.MediaObjectKey.mediaResumed to true
public void onmediaLoad(Observable observable, Object data) {
// Replace <MEDIA_NAME> with the media name.
// Replace <MEDIA_ID> with a media unique identifier.
// Replace <MEDIA_LENGTH> with the media length.
MediaObject mediaInfo = MediaHeartbeat.createMediaObject(
<MEDIA_NAME>,
<MEDIA_ID>,
<MEDIA_LENGTH>,
MediaHeartbeat.StreamType.VOD
);
// Set to true if this is a resume playback scenario
mediaInfo.setValue(MediaHeartbeat.MediaObjectKey.mediaResumed, true);
_heartbeat.trackSessionStart(mediaInfo, mediaMetadata);
}
- (void)onMainmediaLoaded:(NSNotification *)notification {
//Replace <MEDIA_NAME> with the media name.
//Replace <MEDIA_ID> with a media unique identifier.
//Replace <MEDIA_LENGTH> with the media length.
ADBMediaObject *mediaObject =
[ADBMediaHeartbeat createMediaObjectWithName:<MEDIA_NAME>
mediaId:<MEDIA_ID>
length:<MEDIA_LENGTH>
streamType:ADBMediaHeartbeatStreamTypeVOD];
//Set to YES if this user is resuming a previously closed media session
[mediaObject setValue:@(YES) forKey:ADBMediaObjectKeymediaResumed];
[_mediaHeartbeat trackSessionStart:mediaObject data:mediaMetadata];
}
_onmediaLoad = function () {
// Replace <MEDIA_NAME> with the media name.
// Replace <MEDIA_ID> with a media unique identifier.
// Replace <MEDIA_LENGTH> with the media length.
var mediaObject =
MediaHeartbeat.createMediaObject(<MEDIA_NAME>,
<MEDIA_ID,
<MEDIA_LENGTH>,
MediaHeartbeat.StreamType.VOD);
// Set to true if this user is resuming a previously closed media session
mediaObject.setValue(MediaObjectKey.mediaResumed, true);
this._mediaHeartbeat.trackSessionStart(mediaObject, contextData);
};