Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
谢庭 authored and 谢庭 committed Dec 22, 2017
1 parent f225676 commit b9885e8
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 17 deletions.
15 changes: 8 additions & 7 deletions dist/pear-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -19992,7 +19992,7 @@ module.exports = function zeroFill (width, number, pad) {
},{}],134:[function(require,module,exports){
module.exports={
"name": "pearplayer",
"version": "2.4.8",
"version": "2.4.9",
"description": "",
"main": "./dist/pear-player.js",
"dependencies": {
Expand Down Expand Up @@ -20219,7 +20219,6 @@ Dispatcher.prototype.deselect = function (start, end, priority) {

Dispatcher.prototype._slide = function () {
var self = this;

if (self.done) return;
debug('[dispatcher] slide window downloader length:'+self.downloaders.length);
self._fillWindow();
Expand Down Expand Up @@ -20681,7 +20680,7 @@ Dispatcher.prototype._throttle = function (method, context) {

Dispatcher.prototype.autoSlide = function () {
var self = this;

self._slide();
setTimeout(function () {
self._slide();
self._checkDone();
Expand Down Expand Up @@ -21105,7 +21104,8 @@ HttpDownloader.prototype._getChunk = function (begin,end) {
// self.speed = Math.floor((event.total * 1000) / ((self.endTime - self.startTime) * 1024)); //单位: KB/s
self.speed = Math.floor(event.total / (self.endTime - self.startTime)); //单位: KB/s
debug('http speed:' + self.speed + 'KB/s');
self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
// self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
self.meanSpeed = 0.95*self.meanSpeed*self.counter + 0.05*self.speed;
debug('http '+self.uri+' meanSpeed:' + self.meanSpeed + 'KB/s');
if (!self.isAsync) {
if (self.queue.length > 0){ //如果下载队列不为空
Expand Down Expand Up @@ -23205,7 +23205,7 @@ module.exports = {
// }

idles.sort(function (a, b) { //速度从大到小排序
return b.speed - a.speed;
return b.meanSpeed - a.meanSpeed;
});

// for (var i=0;i<idles.length;++i) {
Expand All @@ -23219,7 +23219,7 @@ module.exports = {
});

busys.sort(function (a, b) { //速度从大到小排序
return b.speed - a.speed;
return b.meanSpeed - a.meanSpeed;
});

var ret = idles.concat(busys);
Expand Down Expand Up @@ -24532,7 +24532,8 @@ RTCDownloader.prototype._receive = function (chunk) {
// self.speed = Math.floor(((self.end - self.start) * 1000) / ((self.endTime - self.startTime) * 1024)); //单位: KB/s
self.speed = Math.floor((self.end - self.start + 1) / (self.endTime - self.startTime)); //单位: KB/s
debug('pear_webrtc speed:' + self.speed + 'KB/s');
self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
// self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
self.meanSpeed = 0.95*self.meanSpeed*self.counter + 0.05*self.speed;
debug('datachannel '+self.dc_id+' meanSpeed:' + self.meanSpeed + 'KB/s');

for (var i = 0; i < length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion dist/pear-player.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ index是对应的索引。
## `player.on('canplay', function(delay) {})`
该事件类似video的“canplay”事件,但回调出来的参数是从PearPLayer实例化到开始播放的延迟时间。

- 请参考[`/examples/test.html`](/examples/test.html)来了解API使用方法。
- 请参考[`/examples/player-test.html`](/examples/player-test.html)来了解API使用方法。
- CP接入方法:[Pear FogVDN](https://github.com/PearInc/FogVDN/blob/master/For_CPs.md)


Expand Down
5 changes: 4 additions & 1 deletion docs/change-log.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
### 2.4.7-8
### 2.4.10
- 优化首次下载速度

### 2.4.7-9
- 修改流量上报接口端口号

### 2.4.6
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pearplayer",
"version": "2.4.8",
"version": "2.4.10",
"description": "",
"main": "./dist/pear-player.js",
"dependencies": {
Expand Down
3 changes: 1 addition & 2 deletions src/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ Dispatcher.prototype.deselect = function (start, end, priority) {

Dispatcher.prototype._slide = function () {
var self = this;

if (self.done) return;
debug('[dispatcher] slide window downloader length:'+self.downloaders.length);
self._fillWindow();
Expand Down Expand Up @@ -637,7 +636,7 @@ Dispatcher.prototype._throttle = function (method, context) {

Dispatcher.prototype.autoSlide = function () {
var self = this;

self._slide();
setTimeout(function () {
self._slide();
self._checkDone();
Expand Down
3 changes: 2 additions & 1 deletion src/http-downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ HttpDownloader.prototype._getChunk = function (begin,end) {
// self.speed = Math.floor((event.total * 1000) / ((self.endTime - self.startTime) * 1024)); //单位: KB/s
self.speed = Math.floor(event.total / (self.endTime - self.startTime)); //单位: KB/s
debug('http speed:' + self.speed + 'KB/s');
self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
// self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
self.meanSpeed = 0.95*self.meanSpeed*self.counter + 0.05*self.speed;
debug('http '+self.uri+' meanSpeed:' + self.meanSpeed + 'KB/s');
if (!self.isAsync) {
if (self.queue.length > 0){ //如果下载队列不为空
Expand Down
4 changes: 2 additions & 2 deletions src/node-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
// }

idles.sort(function (a, b) { //速度从大到小排序
return b.speed - a.speed;
return b.meanSpeed - a.meanSpeed;
});

// for (var i=0;i<idles.length;++i) {
Expand All @@ -40,7 +40,7 @@ module.exports = {
});

busys.sort(function (a, b) { //速度从大到小排序
return b.speed - a.speed;
return b.meanSpeed - a.meanSpeed;
});

var ret = idles.concat(busys);
Expand Down
3 changes: 2 additions & 1 deletion src/webrtc-downloader-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ RTCDownloader.prototype._receive = function (chunk) {
// self.speed = Math.floor(((self.end - self.start) * 1000) / ((self.endTime - self.startTime) * 1024)); //单位: KB/s
self.speed = Math.floor((self.end - self.start + 1) / (self.endTime - self.startTime)); //单位: KB/s
debug('pear_webrtc speed:' + self.speed + 'KB/s');
self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
// self.meanSpeed = (self.meanSpeed*self.counter + self.speed)/(++self.counter);
self.meanSpeed = 0.95*self.meanSpeed*self.counter + 0.05*self.speed;
debug('datachannel '+self.dc_id+' meanSpeed:' + self.meanSpeed + 'KB/s');

for (var i = 0; i < length; i++) {
Expand Down

0 comments on commit b9885e8

Please sign in to comment.