Skip to content

Commit

Permalink
Add Brightcove unlayout
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Mar 18, 2016
1 parent 02f9a31 commit 1dbda46
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions extensions/amp-brightcove/0.1/amp-brightcove.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {isLayoutSizeDefined} from '../../../src/layout';
import {loadPromise} from '../../../src/event-helper';
import {addParamsToUrl} from '../../../src/url';
import {dashToCamelCase} from '../../../src/string';
import {removeElement} from '../../../src/dom';

class AmpBrightcove extends AMP.BaseElement {

Expand Down Expand Up @@ -106,6 +107,27 @@ class AmpBrightcove extends AMP.BaseElement {
'pause', 'https://players.brightcove.net');
}
}

/** @override */
unlayoutOnPause() {
return true;
}

/**
* To prevent improperly setup videos (do not include the pauseCallback
* listener script) from playing after being told to pause, we destroy the
* iframe. Once the listener script is updated to inform AMP that it is listening,
* we can prevent the unlayout.
*
* See https://github.com/ampproject/amphtml/issues/2224 for information.
*/
unlayout() {
if (this.iframe_) {
removeElement(this.iframe_);
this.iframe_ = null;
}
return true;
}
};

AMP.registerElement('amp-brightcove', AmpBrightcove);

0 comments on commit 1dbda46

Please sign in to comment.