Skip to content

Commit 1ee7d9e

Browse files
committed
[build] 0.6.1
update chimee-kernel
1 parent 5559e92 commit 1ee7d9e

File tree

7 files changed

+63
-73
lines changed

7 files changed

+63
-73
lines changed

bundle-size/min.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

bundle-size/umd.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/index.browser.js

Lines changed: 53 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**
3-
* chimee v0.6.0
3+
* chimee v0.6.1
44
* (c) 2017 toxic-johann
55
* Released under MIT
66
*/
@@ -5143,6 +5143,10 @@ var defaultConfig$1 = {
51435143
reloadTime: 1500 // video can't play when this time to reload
51445144
};
51455145

5146+
var $const = {
5147+
kernelEvent: ['mediaInfo', 'heartbeat', 'error']
5148+
};
5149+
51465150
var Kernel = function (_CustEvent) {
51475151
_inherits(Kernel, _CustEvent);
51485152

@@ -5162,7 +5166,6 @@ var Kernel = function (_CustEvent) {
51625166
_this.video = videoElement;
51635167
_this.videokernel = _this.selectKernel();
51645168
_this.bindEvents(_this.videokernel, _this.video);
5165-
_this.timer = null;
51665169
return _this;
51675170
}
51685171

@@ -5177,16 +5180,14 @@ var Kernel = function (_CustEvent) {
51775180
value: function bindEvents(videokernel, video) {
51785181
var _this2 = this;
51795182

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;
51895185
}
5186+
$const.kernelEvent.forEach(function (item) {
5187+
videokernel.on(item, function (msg) {
5188+
_this2.emit(item, msg.data);
5189+
});
5190+
});
51905191
}
51915192

51925193
/**
@@ -5198,6 +5199,7 @@ var Kernel = function (_CustEvent) {
51985199
key: 'selectKernel',
51995200
value: function selectKernel() {
52005201
var config = this.config;
5202+
isObject$1(config.preset) || (config.preset = {});
52015203
var box = config.box;
52025204
var src = config.src.toLowerCase();
52035205
// 根据 src 判断 box
@@ -5219,23 +5221,24 @@ var Kernel = function (_CustEvent) {
52195221
Log.error(this.tag, 'You want to play for ' + box + ', but you have not installed the kernel.');
52205222
return;
52215223
}
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()) {
52335226
Log.verbose(this.tag, 'browser is not support mp4 decode, auto switch native player');
5234-
return new Native(this.video, config);
5227+
box = 'native';
52355228
}
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;
52395242
}
52405243
}
52415244

@@ -5247,11 +5250,11 @@ var Kernel = function (_CustEvent) {
52475250
}, {
52485251
key: 'attachMedia',
52495252
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');
52545255
}
5256+
5257+
this.videokernel.attachMedia();
52555258
}
52565259
/**
52575260
* load source
@@ -5262,21 +5265,12 @@ var Kernel = function (_CustEvent) {
52625265
}, {
52635266
key: 'load',
52645267
value: function load(src) {
5265-
var _this3 = this;
5266-
52675268
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');
52795271
}
5272+
5273+
this.videokernel.load(this.config.src);
52805274
}
52815275
/**
52825276
* destory kernel
@@ -5286,13 +5280,11 @@ var Kernel = function (_CustEvent) {
52865280
}, {
52875281
key: 'destroy',
52885282
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');
52955285
}
5286+
5287+
this.videokernel.destroy();
52965288
}
52975289
/**
52985290
* to play
@@ -5302,11 +5294,11 @@ var Kernel = function (_CustEvent) {
53025294
}, {
53035295
key: 'play',
53045296
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');
53095299
}
5300+
5301+
this.videokernel.play();
53105302
}
53115303
/**
53125304
* pause
@@ -5316,11 +5308,10 @@ var Kernel = function (_CustEvent) {
53165308
}, {
53175309
key: 'pause',
53185310
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');
53235313
}
5314+
this.videokernel.pause();
53245315
}
53255316
/**
53265317
* get video currentTime
@@ -5353,11 +5344,10 @@ var Kernel = function (_CustEvent) {
53535344
}, {
53545345
key: 'refresh',
53555346
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');
53605349
}
5350+
this.videokernel.refresh();
53615351
}
53625352
/**
53635353
* get video duration
@@ -8702,7 +8692,7 @@ var Plugin = (_dec$3 = autobindClass(), _dec$3(_class$3 = function (_VideoWrappe
87028692
var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this));
87038693

87048694
_this.destroyed = false;
8705-
_this.VERSION = '0.6.0';
8695+
_this.VERSION = '0.6.1';
87068696
_this.__operable = true;
87078697
_this.__level = 0;
87088698

@@ -10644,7 +10634,7 @@ var Chimee = (_dec = autobindClass(), _dec(_class = (_class2 = (_temp = _class3
1064410634
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'version', [frozen], {
1064510635
enumerable: true,
1064610636
initializer: function initializer() {
10647-
return '0.6.0';
10637+
return '0.6.1';
1064810638
}
1064910639
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'config', [frozen], {
1065010640
enumerable: true,

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**
3-
* chimee v0.6.0
3+
* chimee v0.6.1
44
* (c) 2017 toxic-johann
55
* Released under MIT
66
*/
@@ -1438,7 +1438,7 @@ var Plugin = (_dec$3 = toxicDecorators.autobindClass(), _dec$3(_class$3 = functi
14381438
var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this));
14391439

14401440
_this.destroyed = false;
1441-
_this.VERSION = '0.6.0';
1441+
_this.VERSION = '0.6.1';
14421442
_this.__operable = true;
14431443
_this.__level = 0;
14441444

@@ -3099,7 +3099,7 @@ var Chimee = (_dec = toxicDecorators.autobindClass(), _dec(_class = (_class2 = (
30993099
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'version', [toxicDecorators.frozen], {
31003100
enumerable: true,
31013101
initializer: function initializer() {
3102-
return '0.6.0';
3102+
return '0.6.1';
31033103
}
31043104
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'config', [toxicDecorators.frozen], {
31053105
enumerable: true,

lib/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/**
3-
* chimee v0.6.0
3+
* chimee v0.6.1
44
* (c) 2017 toxic-johann
55
* Released under MIT
66
*/
@@ -1434,7 +1434,7 @@ var Plugin = (_dec$3 = autobindClass(), _dec$3(_class$3 = function (_VideoWrappe
14341434
var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this));
14351435

14361436
_this.destroyed = false;
1437-
_this.VERSION = '0.6.0';
1437+
_this.VERSION = '0.6.1';
14381438
_this.__operable = true;
14391439
_this.__level = 0;
14401440

@@ -3095,7 +3095,7 @@ var Chimee = (_dec = autobindClass(), _dec(_class = (_class2 = (_temp = _class3
30953095
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'version', [frozen], {
30963096
enumerable: true,
30973097
initializer: function initializer() {
3098-
return '0.6.0';
3098+
return '0.6.1';
30993099
}
31003100
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'config', [frozen], {
31013101
enumerable: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chimee",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "a video-player aims to bring wonderful experience on browser",
55
"main": "lib/index.js",
66
"module": "lib/index.mjs",

0 commit comments

Comments
 (0)