1
1
2
2
/**
3
- * chimee v0.6.0
3
+ * chimee v0.6.1
4
4
* (c) 2017 toxic-johann
5
5
* Released under MIT
6
6
*/
@@ -5143,6 +5143,10 @@ var defaultConfig$1 = {
5143
5143
reloadTime : 1500 // video can't play when this time to reload
5144
5144
} ;
5145
5145
5146
+ var $const = {
5147
+ kernelEvent : [ 'mediaInfo' , 'heartbeat' , 'error' ]
5148
+ } ;
5149
+
5146
5150
var Kernel = function ( _CustEvent ) {
5147
5151
_inherits ( Kernel , _CustEvent ) ;
5148
5152
@@ -5162,7 +5166,6 @@ var Kernel = function (_CustEvent) {
5162
5166
_this . video = videoElement ;
5163
5167
_this . videokernel = _this . selectKernel ( ) ;
5164
5168
_this . bindEvents ( _this . videokernel , _this . video ) ;
5165
- _this . timer = null ;
5166
5169
return _this ;
5167
5170
}
5168
5171
@@ -5177,16 +5180,14 @@ var Kernel = function (_CustEvent) {
5177
5180
value : function bindEvents ( videokernel , video ) {
5178
5181
var _this2 = this ;
5179
5182
5180
- if ( videokernel ) {
5181
- videokernel . on ( 'mediaInfo' , function ( mediaInfo ) {
5182
- _this2 . emit ( 'mediaInfo' , mediaInfo ) ;
5183
- } ) ;
5184
-
5185
- video . addEventListener ( 'canplay' , function ( ) {
5186
- clearTimeout ( _this2 . timer ) ;
5187
- _this2 . timer = null ;
5188
- } ) ;
5183
+ if ( ! videokernel ) {
5184
+ return ;
5189
5185
}
5186
+ $const . kernelEvent . forEach ( function ( item ) {
5187
+ videokernel . on ( item , function ( msg ) {
5188
+ _this2 . emit ( item , msg . data ) ;
5189
+ } ) ;
5190
+ } ) ;
5190
5191
}
5191
5192
5192
5193
/**
@@ -5198,6 +5199,7 @@ var Kernel = function (_CustEvent) {
5198
5199
key : 'selectKernel' ,
5199
5200
value : function selectKernel ( ) {
5200
5201
var config = this . config ;
5202
+ isObject$1 ( config . preset ) || ( config . preset = { } ) ;
5201
5203
var box = config . box ;
5202
5204
var src = config . src . toLowerCase ( ) ;
5203
5205
// 根据 src 判断 box
@@ -5219,23 +5221,24 @@ var Kernel = function (_CustEvent) {
5219
5221
Log . error ( this . tag , 'You want to play for ' + box + ', but you have not installed the kernel.' ) ;
5220
5222
return ;
5221
5223
}
5222
- // 调用各个 box
5223
- if ( box === 'native' ) {
5224
- return new Native ( this . video , config ) ;
5225
- } else if ( box === 'flv' ) {
5226
- return new config . preset [ box ] ( this . video , config ) ;
5227
- } else if ( box === 'hls' ) {
5228
- return new config . preset [ box ] ( this . video , config ) ;
5229
- } else if ( box === 'mp4' ) {
5230
- if ( config . preset [ box ] && config . preset [ box ] . isSupport ( ) ) {
5231
- return new config . preset [ box ] ( this . video , config ) ;
5232
- } else {
5224
+ if ( box === 'mp4' ) {
5225
+ if ( ! config . preset [ box ] || ! config . preset [ box ] . isSupport ( ) ) {
5233
5226
Log . verbose ( this . tag , 'browser is not support mp4 decode, auto switch native player' ) ;
5234
- return new Native ( this . video , config ) ;
5227
+ box = 'native' ;
5235
5228
}
5236
- } else {
5237
- Log . error ( this . tag , 'not mactch any player, please check your config' ) ;
5238
- return null ;
5229
+ }
5230
+
5231
+ // 调用各个 box
5232
+ switch ( box ) {
5233
+ case 'native' :
5234
+ return new Native ( this . video , config ) ;
5235
+ case 'mp4' :
5236
+ case 'flv' :
5237
+ case 'hls' :
5238
+ return new config . preset [ box ] ( this . video , config ) ;
5239
+ default :
5240
+ Log . error ( this . tag , 'not mactch any player, please check your config' ) ;
5241
+ return ;
5239
5242
}
5240
5243
}
5241
5244
@@ -5247,11 +5250,11 @@ var Kernel = function (_CustEvent) {
5247
5250
} , {
5248
5251
key : 'attachMedia' ,
5249
5252
value : function attachMedia ( ) {
5250
- if ( this . videokernel ) {
5251
- this . videokernel . attachMedia ( ) ;
5252
- } else {
5253
- Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5253
+ if ( ! this . videokernel ) {
5254
+ return Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5254
5255
}
5256
+
5257
+ this . videokernel . attachMedia ( ) ;
5255
5258
}
5256
5259
/**
5257
5260
* load source
@@ -5262,21 +5265,12 @@ var Kernel = function (_CustEvent) {
5262
5265
} , {
5263
5266
key : 'load' ,
5264
5267
value : function load ( src ) {
5265
- var _this3 = this ;
5266
-
5267
5268
this . config . src = src || this . config . src ;
5268
- if ( this . videokernel && this . config . src ) {
5269
- this . videokernel . load ( this . config . src ) ;
5270
- if ( ! this . timer && this . box !== 'hls' ) {
5271
- this . timer = setTimeout ( function ( ) {
5272
- _this3 . timer = null ;
5273
- _this3 . pause ( ) ;
5274
- _this3 . refresh ( ) ;
5275
- } , this . config . reloadTime ) ;
5276
- }
5277
- } else {
5278
- Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5269
+ if ( ! this . videokernel || ! this . config . src ) {
5270
+ return Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5279
5271
}
5272
+
5273
+ this . videokernel . load ( this . config . src ) ;
5280
5274
}
5281
5275
/**
5282
5276
* destory kernel
@@ -5286,13 +5280,11 @@ var Kernel = function (_CustEvent) {
5286
5280
} , {
5287
5281
key : 'destroy' ,
5288
5282
value : function destroy ( ) {
5289
- if ( this . videokernel ) {
5290
- this . videokernel . destroy ( ) ;
5291
- clearTimeout ( this . timer ) ;
5292
- this . timer = null ;
5293
- } else {
5294
- Log . error ( this . tag , 'videokernel is not exit' ) ;
5283
+ if ( ! this . videokernel ) {
5284
+ return Log . error ( this . tag , 'videokernel is not exit' ) ;
5295
5285
}
5286
+
5287
+ this . videokernel . destroy ( ) ;
5296
5288
}
5297
5289
/**
5298
5290
* to play
@@ -5302,11 +5294,11 @@ var Kernel = function (_CustEvent) {
5302
5294
} , {
5303
5295
key : 'play' ,
5304
5296
value : function play ( ) {
5305
- if ( this . videokernel ) {
5306
- this . videokernel . play ( ) ;
5307
- } else {
5308
- Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5297
+ if ( ! this . videokernel ) {
5298
+ return Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5309
5299
}
5300
+
5301
+ this . videokernel . play ( ) ;
5310
5302
}
5311
5303
/**
5312
5304
* pause
@@ -5316,11 +5308,10 @@ var Kernel = function (_CustEvent) {
5316
5308
} , {
5317
5309
key : 'pause' ,
5318
5310
value : function pause ( ) {
5319
- if ( this . videokernel && this . config . src ) {
5320
- this . videokernel . pause ( ) ;
5321
- } else {
5322
- Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5311
+ if ( ! this . videokernel || ! this . config . src ) {
5312
+ return Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5323
5313
}
5314
+ this . videokernel . pause ( ) ;
5324
5315
}
5325
5316
/**
5326
5317
* get video currentTime
@@ -5353,11 +5344,10 @@ var Kernel = function (_CustEvent) {
5353
5344
} , {
5354
5345
key : 'refresh' ,
5355
5346
value : function refresh ( ) {
5356
- if ( this . videokernel ) {
5357
- this . videokernel . refresh ( ) ;
5358
- } else {
5359
- Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5347
+ if ( ! this . videokernel ) {
5348
+ return Log . error ( this . tag , 'videokernel is not already, must init player' ) ;
5360
5349
}
5350
+ this . videokernel . refresh ( ) ;
5361
5351
}
5362
5352
/**
5363
5353
* get video duration
@@ -8702,7 +8692,7 @@ var Plugin = (_dec$3 = autobindClass(), _dec$3(_class$3 = function (_VideoWrappe
8702
8692
var _this = _possibleConstructorReturn ( this , ( Plugin . __proto__ || _Object$getPrototypeOf ( Plugin ) ) . call ( this ) ) ;
8703
8693
8704
8694
_this . destroyed = false ;
8705
- _this . VERSION = '0.6.0 ' ;
8695
+ _this . VERSION = '0.6.1 ' ;
8706
8696
_this . __operable = true ;
8707
8697
_this . __level = 0 ;
8708
8698
@@ -10644,7 +10634,7 @@ var Chimee = (_dec = autobindClass(), _dec(_class = (_class2 = (_temp = _class3
10644
10634
} ) , _descriptor2 = _applyDecoratedDescriptor ( _class2 . prototype , 'version' , [ frozen ] , {
10645
10635
enumerable : true ,
10646
10636
initializer : function initializer ( ) {
10647
- return '0.6.0 ' ;
10637
+ return '0.6.1 ' ;
10648
10638
}
10649
10639
} ) , _descriptor3 = _applyDecoratedDescriptor ( _class2 . prototype , 'config' , [ frozen ] , {
10650
10640
enumerable : true ,
0 commit comments