Sha256: 2817d09eb7c3a4640e8c40e135b0eb3cf15328391b65b6a33cfcb2a667937d37

Contents?: true

Size: 825 Bytes

Versions: 10

Compression:

Stored size: 825 Bytes

Contents

/*global Promise*/

// Chrome returns a promise from `play` that is rejected if another
// operation (like calling `pause` or updating the source) happens
// before playing started. If the promise rejection is not handled,
// the operation that caused `play` to abort will fail with an
// exception. Code following the operation will not be executed. Catch
// and ignore the promise to prevent this.
pageflow.mediaPlayer.catchPlayerPromise = function(player) {
  var originalPlay = player.play;

  player.play = function(/* arguments */) {
    var result = originalPlay.apply(player, arguments);

    if (result && (typeof Promise !== 'undefined') && (result instanceof Promise)) {
      result.catch(function() {
        pageflow.log('Caught pending play exception - continuing');
      });
    }

    return result;
  };
};

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pageflow-13.0.0.beta6 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-13.0.0.beta5 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-13.0.0.beta4 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-13.0.0.beta3 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-13.0.0.beta2 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-13.0.0.beta1 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-12.2.0 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-12.1.0 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-12.0.4 app/assets/javascripts/pageflow/media_player/catch_play_promise.js
pageflow-12.0.3 app/assets/javascripts/pageflow/media_player/catch_play_promise.js