Skip to content

Commit

Permalink
Fem 2089 (#24)
Browse files Browse the repository at this point in the history
* FEM-2089
- When Impression event fired player does not know its current position. This might have effect on the decision if playbackType is DVR or Live. In that case we should assume that playbackType is Live.
  • Loading branch information
AntonAFA authored and giladna committed Jun 17, 2018
1 parent 5daa1cc commit f35762f
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private KavaMediaEntryType decideOnPlaybackType(KavaEvents event) {
if (KavaMediaEntryType.Vod.name().equals(metadataPlaybackType)) {
kavaPlaybackType = KavaMediaEntryType.Vod;
} else if (PKMediaEntry.MediaEntryType.Live.name().equals(metadataPlaybackType)) {
kavaPlaybackType = hasDvr() ? KavaMediaEntryType.Dvr : KavaMediaEntryType.Live;
kavaPlaybackType = hasDvr(event) ? KavaMediaEntryType.Dvr : KavaMediaEntryType.Live;
} else {
//If there is no playback type in metadata, obtain it from player as fallback.
if (player == null || event == KavaEvents.ERROR) {
Expand All @@ -394,7 +394,7 @@ private KavaMediaEntryType decideOnPlaybackType(KavaEvents event) {
if (!player.isLiveStream()) {
kavaPlaybackType = KavaMediaEntryType.Vod;
} else {
kavaPlaybackType = hasDvr() ? KavaMediaEntryType.Dvr : KavaMediaEntryType.Live;
kavaPlaybackType = hasDvr(event) ? KavaMediaEntryType.Dvr : KavaMediaEntryType.Live;
}
}
}
Expand All @@ -404,13 +404,18 @@ private KavaMediaEntryType decideOnPlaybackType(KavaEvents event) {

/**
* Chceck if current playback state is in LIVE or DVR mode.
*
* @param - Event type. When IMPRESSION event sent player still does not know its current position.
* So in this case we can assume that playbackType is live.
* @return - true if distance from live edge grater the requested dvr threshold.
*/
private boolean hasDvr() {
private boolean hasDvr(KavaEvents event) {
if (player == null) {
return false;
}
if(event == KavaEvents.IMPRESSION) {
//For Impression event assume that playbackType is live.
return false;
}

if (player.isLiveStream()) {
long distanceFromLive = player.getDuration() - player.getCurrentPosition();
Expand Down

0 comments on commit f35762f

Please sign in to comment.