@@ -148,6 +148,8 @@ return /******/ (function(modules) { // webpackBootstrap
148
148
149
149
var _assetsCopy2 = _interopRequireDefault ( _assetsCopy ) ;
150
150
151
+ var EVENTS = [ 'onAbort' , 'onCanPlay' , 'onCanPlayThrough' , 'onDurationChange' , 'onEmptied' , 'onEncrypted' , 'onEnded' , 'onError' , 'onLoadedData' , 'onLoadedMetadata' , 'onLoadStart' , 'onPause' , 'onPlay' , 'onPlaying' , 'onProgress' , 'onRateChange' , 'onSeeked' , 'onSeeking' , 'onStalled' , 'onSuspend' , 'onTimeUpdate' , 'onVolumeChange' , 'onWaiting' ] ;
152
+
151
153
var Video = _react2 [ 'default' ] . createClass ( {
152
154
displayName : 'Video' ,
153
155
@@ -190,9 +192,23 @@ return /******/ (function(modules) { // webpackBootstrap
190
192
* @return {undefined }
191
193
*/
192
194
componentWillMount : function componentWillMount ( ) {
195
+ var _this = this ;
196
+
193
197
// Also bind 'this' as we call _updateStateFromVideo outside
194
198
// of Reacts synthetic events as well.
195
199
this . _updateStateFromVideo = ( 0 , _lodashThrottle2 [ 'default' ] ) ( this . updateStateFromVideo , 100 ) . bind ( this ) ;
200
+ // Set up all React media events and call method
201
+ // on props if provided.
202
+ this . mediaEventProps = EVENTS . reduce ( function ( p , c ) {
203
+ p [ c ] = function ( ) {
204
+ if ( c in _this . props && typeof _this . props [ c ] === 'function' ) {
205
+ // A prop exists for this mediaEvent, call it.
206
+ _this . props [ c ] ( ) ;
207
+ }
208
+ _this . _updateStateFromVideo ( ) ;
209
+ } ;
210
+ return p ;
211
+ } , { } ) ;
196
212
} ,
197
213
198
214
/**
@@ -433,7 +449,7 @@ return /******/ (function(modules) { // webpackBootstrap
433
449
} ,
434
450
435
451
render : function render ( ) {
436
- var _this = this ;
452
+ var _this2 = this ;
437
453
438
454
// If controls prop is provided remove it
439
455
// and use our own controls.
@@ -453,34 +469,12 @@ return /******/ (function(modules) { // webpackBootstrap
453
469
_extends ( { } , otherProps , {
454
470
className : 'video__el' ,
455
471
ref : function ( el ) {
456
- _this . videoEl = el ;
457
- } ,
472
+ _this2 . videoEl = el ;
473
+ }
458
474
// We have throttled `_updateStateFromVideo` so listen to
459
475
// every available Media event that React allows and
460
476
// infer the Video state in that method from the Video properties.
461
- onAbort : this . _updateStateFromVideo ,
462
- onCanPlay : this . _updateStateFromVideo ,
463
- onCanPlayThrough : this . _updateStateFromVideo ,
464
- onDurationChange : this . _updateStateFromVideo ,
465
- onEmptied : this . _updateStateFromVideo ,
466
- onEncrypted : this . _updateStateFromVideo ,
467
- onEnded : this . _updateStateFromVideo ,
468
- onError : this . _updateStateFromVideo ,
469
- onLoadedData : this . _updateStateFromVideo ,
470
- onLoadedMetadata : this . _updateStateFromVideo ,
471
- onLoadStart : this . _updateStateFromVideo ,
472
- onPause : this . _updateStateFromVideo ,
473
- onPlay : this . _updateStateFromVideo ,
474
- onPlaying : this . _updateStateFromVideo ,
475
- onProgress : this . _updateStateFromVideo ,
476
- onRateChange : this . _updateStateFromVideo ,
477
- onSeeked : this . _updateStateFromVideo ,
478
- onSeeking : this . _updateStateFromVideo ,
479
- onStalled : this . _updateStateFromVideo ,
480
- onSuspend : this . _updateStateFromVideo ,
481
- onTimeUpdate : this . _updateStateFromVideo ,
482
- onVolumeChange : this . _updateStateFromVideo ,
483
- onWaiting : this . _updateStateFromVideo } ) ,
477
+ } , this . mediaEventProps ) ,
484
478
this . renderSources ( )
485
479
) ,
486
480
controls ? this . renderControls ( ) : ''
0 commit comments