Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEC-12185 Exposed AdResponse APIs on MediaInfoUtils #32

Merged
merged 4 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ var pendingResult: PendingResult<RemoteMediaClient.MediaChannelResult>? = null
val loadOptions = MediaLoadOptions.Builder().setAutoplay(true).setPlayPosition(0L).build()

```
> **Important: In case for Live Media, `setPlayPosition` should be passed `-1`**
> **NOTE: In case for Live Media, `setPlayPosition` should be passed `MediaInfoUtils.LIVE_EDGE` or `-1000L`**.
GouravSna marked this conversation as resolved.
Show resolved Hide resolved
GouravSna marked this conversation as resolved.
Show resolved Hide resolved
>
> **In case, for VOD assets, app wants to pass the start position for the player, this parameter can be used.**

##### 7. Finally load the `RemoteMediaClient`,

Expand All @@ -211,15 +213,36 @@ pendingResult = remoteMediaClient!!.load(mediaInfo object, loadOptions)

For VAST Ad URL, pass AdUrl in `MediaInfoUtils`,

`val adsConfig = MediaInfoUtils.createAdsConfigVastInPosition(0, adTagUrl)`
`val adsConfig = MediaInfoUtils.createAdsConfigVastInPosition(startPosition, adTagUrl)`

For VMAP, pass AdUrl like this,

`val adsConfig = MediaInfoUtils.createAdsConfigVmap(adTagUrl)`

For VAST Ad response XML, pass ad response to

`MediaInfoUtils.createAdsResponseConfigVastInPosition(startPosition, adResponse)`

For VMAP Ad response XML, pass ad response to

`MediaInfoUtils.createAdResponseConfigVmap(adResponse)`

Then pass the `AdsConfig` object to `setAdsConfig` on the respective cast builder object (OTT/OVP or Basic)

`phoenixCastBuilder.setAdsConfig(Ads_Config)`
**OTT:** `phoenixCastBuilder.setAdsConfig(Ads_Config)`

**OVP:** `ovpV3CastBuilder.setAdsConfig(Ads_Config)`

**BASIC:**`basicCastBuilder.setAdsConfig(Ads_Config)`

`startPosition` is the cast player start position. Let's suppose media is playing back at some position x seconds and when the user connects then app want to media to start from x seconds then use this parameter. This is only meant for VAST ad url/response. It will be one time ad playback.

For VMAP, anyways based on the time offset given in the VMAP, ads will be played.

> **NOTE : We have [IMA Plugin](https://github.com/kaltura/playkit-android-ima) for Ad playback. That is only meant for in app Ad playback. IMA Plugin does not help to play the Ads while using the cast.**

> **For Cast the above given configuration is must to have otherwise Ad will not play in GoogleCast.**


#### Pass External Subtitles for the media

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@
import java.util.ArrayList;
import java.util.List;

/**
* Utility class may be used to build the OVP, OTT media info objects
* for Cast builders.
* Along with that AdConfig objects can also be build
* using Ad URL or Ad response
*/
public class MediaInfoUtils {

/**
* Must to set variable in `setPlayPosition`
* for the LIVE medias
*/
public static final int LIVE_EDGE = -1000;

public static MediaInfo buildOVPMediaInfo(String entryId,
Expand Down Expand Up @@ -88,6 +98,13 @@ public static MediaInfo buildOTTMediaInfo(String entryId,
return mediaInfo;
}

/**
* Create the VAST AdConfig for GoogleCast with playback position
*
* @param playbackPositionInMs start position in miliseconds
* @param adTagUrl VAST ad url
* @return AdsConfig
*/
public static AdsConfig createAdsConfigVastInPosition(long playbackPositionInMs, String adTagUrl) {
List<AdBreakClipInfo> adBreakClipInfoList = new ArrayList<>();
VastAdsRequest vastRequest = new VastAdsRequest.Builder().setAdTagUrl(adTagUrl).build();
Expand All @@ -99,14 +116,51 @@ public static AdsConfig createAdsConfigVastInPosition(long playbackPositionInMs,
AdBreakInfo adBreakInfo1 = new AdBreakInfo.Builder(playbackPositionInMs).setBreakClipIds(breakClipIds).setId("101").build();
adBreakInfoList.add(adBreakInfo1);

AdsConfig adsConfig = new VastAdsConfig().setVastAdBreakClipInfoList(adBreakClipInfoList).setVastAdBreakInfoList(adBreakInfoList);
return adsConfig;
return new VastAdsConfig().setVastAdBreakClipInfoList(adBreakClipInfoList).setVastAdBreakInfoList(adBreakInfoList);
}

/**
* Create the VAST AdConfig for GoogleCast with playback position
*
* @param playbackPositionInMs start position in miliseconds
* @param adTagResponse VAST XML ad response
* @return AdsConfig
*/
public static AdsConfig createAdsResponseConfigVastInPosition(long playbackPositionInMs, String adTagResponse) {
List<AdBreakClipInfo> adBreakClipInfoList = new ArrayList<>();
VastAdsRequest vastRequest = new VastAdsRequest.Builder().setAdsResponse(adTagResponse).build();
AdBreakClipInfo clipInfo1 = new AdBreakClipInfo.Builder("100").setVastAdsRequest(vastRequest).build();
adBreakClipInfoList.add(clipInfo1);

List<AdBreakInfo> adBreakInfoList = new ArrayList<>();
final String[] breakClipIds = new String[]{"100"};
AdBreakInfo adBreakInfo1 = new AdBreakInfo.Builder(playbackPositionInMs).setBreakClipIds(breakClipIds).setId("101").build();
adBreakInfoList.add(adBreakInfo1);

return new VastAdsConfig().setVastAdBreakClipInfoList(adBreakClipInfoList).setVastAdBreakInfoList(adBreakInfoList);
}

/**
* Create the VMAP AdConfig for GoogleCast
*
* @param adTagUrl VMAP ad url
* @return AdsConfig
*/
public static AdsConfig createAdsConfigVmap(String adTagUrl) {
AdsConfig adsConfig = new VmapAdsConfig()
return new VmapAdsConfig()
.setVmapAdRequest(new VmapAdRequest()
.setAdTagUrl(adTagUrl));
return adsConfig;
}

/**
* Create the VMAP AdConfig for GoogleCast
*
* @param adTagResponse VMAP XML ad response
* @return AdsConfig
*/
public static AdsConfig createAdResponseConfigVmap(String adTagResponse) {
return new VmapAdsConfig()
.setVmapAdRequest(new VmapAdRequest()
.setAdsResponse(adTagResponse));
}
}