Full-event replay (FER) is a VOD asset that acts, in terms of ad insertion, as a live/DVR asset, so your application must take steps to ensure that ads are placed correctly.
For live content, the PSDK uses the metadata/cues presented in the manifest to determine where to place ads. However, sometimes live/linear content looks like VOD content, for example, when live content completes, an EXT-X-ENDLIST tag is appended to the live manifest. For HLS, the presence of the EXT-X-ENDLIST tag means that the stream is a VOD stream, and there is no way for the PSDK to automatically differentiate it from a normal VOD stream so that it can insert ads correctly.
Therefore, your application must notify the PSDK of this situation by specifying the AdSignalingMode.
For a FER stream, you do not want the Ad Decisioning server to provide the list of ad breaks that need to be inserted on the timeline prior to beginning playback, as would be usual for VOD. Instead, by specifying a different signaling mode, the PSDK reads all the cue points from the FER manifest and goes to the ad server for each cue point to request an ad break (similar to live/DVR).
Besides each request associated with a cue point, the PSDK makes an additional ad request for pre-roll ads.
Valid values are DEFAULT, SERVER_MAP, and MANIFEST_CUES.
You must set the ad signaling mode before calling prepareToPlay. After the PSDK has started resolving and placing ads on the timeline, any change to the ad signaling mode is ignored. The recommended way is to set it when creating the advertising metadata for the resource (when creating the AuditudeSettings object).
AuditudeSettings auditudeSettings = new AuditudeSettings();
auditudeSettings.setSignalingMode(AdSignalingMode.MANIFEST_CUES);
auditudeSettings.setDomain("your-auditude-domain");
auditudeSettings.setZoneId("your-auditude-zone-id");
auditudeSettings.setMediaId("your-media-id");
// set additional targeting parameters or custom parameters
MetadataNode mediaMetadata = new MetadataNode();
mediaMetadata.setNode(DefaultMetadataKeys.AUDITUDE_METADATA_KEY.getValue(), auditudeSettings);
MediaResource mediaResource = MediaResource.createFromUrl("your-stream-url", mediaMetadata);
final MediaPlayer mediaPlayer = DefaultMediaPlayer.create(getApplicationContext());
mediaPlayer.addEventListener(MediaPlayer.Event.PLAYBACK, new MediaPlayer.PlaybackEventListener() {
@Override
public void onPrepared() {
// the player is prepared and all ads have been placed
mediaPlayer.play();
}
@Override
public void onUpdated() {
}
@Override
public void onTimedMetadata(TimedMetadata timedMetadata) {
}
@Override
public void onTimelineUpdated() {
}
@Override
public void onPlayStart() {
// the playback has started we can update UI control
// for example: remove starting/buffering slate if needed
}
@Override
public void onPlayComplete() {
// playback has reached the end of stream ( ads included )
// if we want to rewind we can call mediaPlayer.seek(mediaPlayer.getSeekableRange().getBegin());
}
@Override
public void onStateChanged(MediaPlayer.PlayerState state, MediaPlayerNotification notification) {
if (state == MediaPlayer.PlayerState.INITIALIZED) {
mediaPlayer.prepareToPlay();
}
}
@Override
public void onSizeAvailable(long height, long width) {
// video size was update
// you can use height and width to resize the media player view
}
});
mediaPlayer.replaceCurrentItem(mediaResource);