Skip to content

Commit

Permalink
馃悰Fixes ima-video race condition and percentage played (ampproject#24900)
Browse files Browse the repository at this point in the history
Fixes the race condition that causes the ima-video player to freeze with slow network connection. Also added event trigger to calculate percentage played.
Closes ampproject#23356
  • Loading branch information
Micajuine Ho authored and joshuarrrr committed Oct 22, 2019
1 parent e168e1e commit a2cc90d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions extensions/amp-ima-video/0.1/amp-ima-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class AmpImaVideo extends AMP.BaseElement {
}
if (videoEvent == ImaPlayerData.IMA_PLAYER_DATA) {
this.playerData_ = /** @type {!ImaPlayerData} */ (eventData['data']);
this.element.dispatchCustomEvent(VideoEvents.LOADEDMETADATA);
return;
}
if (videoEvent == 'fullscreenchange') {
Expand Down
5 changes: 3 additions & 2 deletions src/service/video-manager-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,8 +1433,9 @@ export class AnalyticsPercentageTracker {
const {video} = this.entry_;
const duration = video.getDuration();

// Livestreams or videos with no duration information available.
if (!duration || isNaN(duration) || duration <= 0) {
// Livestreams or videos with no duration information available,
// where 1 second is the default duration for some video players
if (!duration || isNaN(duration) || duration <= 1) {
return false;
}

Expand Down

0 comments on commit a2cc90d

Please sign in to comment.