Commit 0a2d60b9 by libai

测试

parent 026a1274
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license * @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version v4.2.5+7f2b526d * @version 4.1.0
*/ */
(function (global, factory) { (function (global, factory) {
...@@ -15,30 +15,27 @@ ...@@ -15,30 +15,27 @@
}(this, (function () { 'use strict'; }(this, (function () { 'use strict';
function objectOrFunction(x) { function objectOrFunction(x) {
var type = typeof x; return typeof x === 'function' || typeof x === 'object' && x !== null;
return x !== null && (type === 'object' || type === 'function');
} }
function isFunction(x) { function isFunction(x) {
return typeof x === 'function'; return typeof x === 'function';
} }
var _isArray = undefined;
if (!Array.isArray) {
var _isArray = void 0;
if (Array.isArray) {
_isArray = Array.isArray;
} else {
_isArray = function (x) { _isArray = function (x) {
return Object.prototype.toString.call(x) === '[object Array]'; return Object.prototype.toString.call(x) === '[object Array]';
}; };
} else {
_isArray = Array.isArray;
} }
var isArray = _isArray; var isArray = _isArray;
var len = 0; var len = 0;
var vertxNext = void 0; var vertxNext = undefined;
var customSchedulerFn = void 0; var customSchedulerFn = undefined;
var asap = function asap(callback, arg) { var asap = function asap(callback, arg) {
queue[len] = callback; queue[len] = callback;
...@@ -67,7 +64,7 @@ ...@@ -67,7 +64,7 @@
var browserWindow = typeof window !== 'undefined' ? window : undefined; var browserWindow = typeof window !== 'undefined' ? window : undefined;
var browserGlobal = browserWindow || {}; var browserGlobal = browserWindow || {};
var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]';
// test for web worker but not in IE10 // test for web worker but not in IE10
var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
...@@ -138,7 +135,8 @@ ...@@ -138,7 +135,8 @@
function attemptVertx() { function attemptVertx() {
try { try {
var vertx = Function('return this')().require('vertx'); var r = _dereq_;
var vertx = r('vertx');
vertxNext = vertx.runOnLoop || vertx.runOnContext; vertxNext = vertx.runOnLoop || vertx.runOnContext;
return useVertxTimer(); return useVertxTimer();
} catch (e) { } catch (e) {
...@@ -146,7 +144,7 @@ ...@@ -146,7 +144,7 @@
} }
} }
var scheduleFlush = void 0; var scheduleFlush = undefined;
// Decide what async method to use to triggering processing of queued callbacks: // Decide what async method to use to triggering processing of queued callbacks:
if (isNode) { if (isNode) {
scheduleFlush = useNextTick(); scheduleFlush = useNextTick();
...@@ -161,6 +159,8 @@ ...@@ -161,6 +159,8 @@
} }
function then(onFulfillment, onRejection) { function then(onFulfillment, onRejection) {
var _arguments = arguments;
var parent = this; var parent = this;
var child = new this.constructor(noop); var child = new this.constructor(noop);
...@@ -171,12 +171,13 @@ ...@@ -171,12 +171,13 @@
var _state = parent._state; var _state = parent._state;
if (_state) { if (_state) {
var callback = arguments[_state - 1]; (function () {
var callback = _arguments[_state - 1];
asap(function () { asap(function () {
return invokeCallback(_state, child, callback, parent._result); return invokeCallback(_state, child, callback, parent._result);
}); });
})();
} else { } else {
subscribe(parent, child, onFulfillment, onRejection); subscribe(parent, child, onFulfillment, onRejection);
} }
...@@ -215,7 +216,7 @@ ...@@ -215,7 +216,7 @@
@return {Promise} a promise that will become fulfilled with the given @return {Promise} a promise that will become fulfilled with the given
`value` `value`
*/ */
function resolve$1(object) { function resolve(object) {
/*jshint validthis:true */ /*jshint validthis:true */
var Constructor = this; var Constructor = this;
...@@ -224,11 +225,11 @@ ...@@ -224,11 +225,11 @@
} }
var promise = new Constructor(noop); var promise = new Constructor(noop);
resolve(promise, object); _resolve(promise, object);
return promise; return promise;
} }
var PROMISE_ID = Math.random().toString(36).substring(2); var PROMISE_ID = Math.random().toString(36).substring(16);
function noop() {} function noop() {}
...@@ -236,7 +237,7 @@ ...@@ -236,7 +237,7 @@
var FULFILLED = 1; var FULFILLED = 1;
var REJECTED = 2; var REJECTED = 2;
var TRY_CATCH_ERROR = { error: null }; var GET_THEN_ERROR = new ErrorObject();
function selfFulfillment() { function selfFulfillment() {
return new TypeError("You cannot resolve a promise with itself"); return new TypeError("You cannot resolve a promise with itself");
...@@ -250,29 +251,29 @@ ...@@ -250,29 +251,29 @@
try { try {
return promise.then; return promise.then;
} catch (error) { } catch (error) {
TRY_CATCH_ERROR.error = error; GET_THEN_ERROR.error = error;
return TRY_CATCH_ERROR; return GET_THEN_ERROR;
} }
} }
function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
try { try {
then$$1.call(value, fulfillmentHandler, rejectionHandler); then.call(value, fulfillmentHandler, rejectionHandler);
} catch (e) { } catch (e) {
return e; return e;
} }
} }
function handleForeignThenable(promise, thenable, then$$1) { function handleForeignThenable(promise, thenable, then) {
asap(function (promise) { asap(function (promise) {
var sealed = false; var sealed = false;
var error = tryThen(then$$1, thenable, function (value) { var error = tryThen(then, thenable, function (value) {
if (sealed) { if (sealed) {
return; return;
} }
sealed = true; sealed = true;
if (thenable !== value) { if (thenable !== value) {
resolve(promise, value); _resolve(promise, value);
} else { } else {
fulfill(promise, value); fulfill(promise, value);
} }
...@@ -282,12 +283,12 @@ ...@@ -282,12 +283,12 @@
} }
sealed = true; sealed = true;
reject(promise, reason); _reject(promise, reason);
}, 'Settle: ' + (promise._label || ' unknown promise')); }, 'Settle: ' + (promise._label || ' unknown promise'));
if (!sealed && error) { if (!sealed && error) {
sealed = true; sealed = true;
reject(promise, error); _reject(promise, error);
} }
}, promise); }, promise);
} }
...@@ -296,36 +297,36 @@ ...@@ -296,36 +297,36 @@
if (thenable._state === FULFILLED) { if (thenable._state === FULFILLED) {
fulfill(promise, thenable._result); fulfill(promise, thenable._result);
} else if (thenable._state === REJECTED) { } else if (thenable._state === REJECTED) {
reject(promise, thenable._result); _reject(promise, thenable._result);
} else { } else {
subscribe(thenable, undefined, function (value) { subscribe(thenable, undefined, function (value) {
return resolve(promise, value); return _resolve(promise, value);
}, function (reason) { }, function (reason) {
return reject(promise, reason); return _reject(promise, reason);
}); });
} }
} }
function handleMaybeThenable(promise, maybeThenable, then$$1) { function handleMaybeThenable(promise, maybeThenable, then$$) {
if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) {
handleOwnThenable(promise, maybeThenable); handleOwnThenable(promise, maybeThenable);
} else { } else {
if (then$$1 === TRY_CATCH_ERROR) { if (then$$ === GET_THEN_ERROR) {
reject(promise, TRY_CATCH_ERROR.error); _reject(promise, GET_THEN_ERROR.error);
TRY_CATCH_ERROR.error = null; GET_THEN_ERROR.error = null;
} else if (then$$1 === undefined) { } else if (then$$ === undefined) {
fulfill(promise, maybeThenable); fulfill(promise, maybeThenable);
} else if (isFunction(then$$1)) { } else if (isFunction(then$$)) {
handleForeignThenable(promise, maybeThenable, then$$1); handleForeignThenable(promise, maybeThenable, then$$);
} else { } else {
fulfill(promise, maybeThenable); fulfill(promise, maybeThenable);
} }
} }
} }
function resolve(promise, value) { function _resolve(promise, value) {
if (promise === value) { if (promise === value) {
reject(promise, selfFulfillment()); _reject(promise, selfFulfillment());
} else if (objectOrFunction(value)) { } else if (objectOrFunction(value)) {
handleMaybeThenable(promise, value, getThen(value)); handleMaybeThenable(promise, value, getThen(value));
} else { } else {
...@@ -354,7 +355,7 @@ ...@@ -354,7 +355,7 @@
} }
} }
function reject(promise, reason) { function _reject(promise, reason) {
if (promise._state !== PENDING) { if (promise._state !== PENDING) {
return; return;
} }
...@@ -368,7 +369,6 @@ ...@@ -368,7 +369,6 @@
var _subscribers = parent._subscribers; var _subscribers = parent._subscribers;
var length = _subscribers.length; var length = _subscribers.length;
parent._onerror = null; parent._onerror = null;
_subscribers[length] = child; _subscribers[length] = child;
...@@ -388,8 +388,8 @@ ...@@ -388,8 +388,8 @@
return; return;
} }
var child = void 0, var child = undefined,
callback = void 0, callback = undefined,
detail = promise._result; detail = promise._result;
for (var i = 0; i < subscribers.length; i += 3) { for (var i = 0; i < subscribers.length; i += 3) {
...@@ -406,6 +406,12 @@ ...@@ -406,6 +406,12 @@
promise._subscribers.length = 0; promise._subscribers.length = 0;
} }
function ErrorObject() {
this.error = null;
}
var TRY_CATCH_ERROR = new ErrorObject();
function tryCatch(callback, detail) { function tryCatch(callback, detail) {
try { try {
return callback(detail); return callback(detail);
...@@ -417,10 +423,10 @@ ...@@ -417,10 +423,10 @@
function invokeCallback(settled, promise, callback, detail) { function invokeCallback(settled, promise, callback, detail) {
var hasCallback = isFunction(callback), var hasCallback = isFunction(callback),
value = void 0, value = undefined,
error = void 0, error = undefined,
succeeded = void 0, succeeded = undefined,
failed = void 0; failed = undefined;
if (hasCallback) { if (hasCallback) {
value = tryCatch(callback, detail); value = tryCatch(callback, detail);
...@@ -434,7 +440,7 @@ ...@@ -434,7 +440,7 @@
} }
if (promise === value) { if (promise === value) {
reject(promise, cannotReturnOwn()); _reject(promise, cannotReturnOwn());
return; return;
} }
} else { } else {
...@@ -445,25 +451,25 @@ ...@@ -445,25 +451,25 @@
if (promise._state !== PENDING) { if (promise._state !== PENDING) {
// noop // noop
} else if (hasCallback && succeeded) { } else if (hasCallback && succeeded) {
resolve(promise, value); _resolve(promise, value);
} else if (failed) { } else if (failed) {
reject(promise, error); _reject(promise, error);
} else if (settled === FULFILLED) { } else if (settled === FULFILLED) {
fulfill(promise, value); fulfill(promise, value);
} else if (settled === REJECTED) { } else if (settled === REJECTED) {
reject(promise, value); _reject(promise, value);
} }
} }
function initializePromise(promise, resolver) { function initializePromise(promise, resolver) {
try { try {
resolver(function resolvePromise(value) { resolver(function resolvePromise(value) {
resolve(promise, value); _resolve(promise, value);
}, function rejectPromise(reason) { }, function rejectPromise(reason) {
reject(promise, reason); _reject(promise, reason);
}); });
} catch (e) { } catch (e) {
reject(promise, e); _reject(promise, e);
} }
} }
...@@ -479,11 +485,6 @@ ...@@ -479,11 +485,6 @@
promise._subscribers = []; promise._subscribers = [];
} }
function validationError() {
return new Error('Array Methods must be provided an Array');
}
var Enumerator = function () {
function Enumerator(Constructor, input) { function Enumerator(Constructor, input) {
this._instanceConstructor = Constructor; this._instanceConstructor = Constructor;
this.promise = new Constructor(noop); this.promise = new Constructor(noop);
...@@ -493,6 +494,7 @@ ...@@ -493,6 +494,7 @@
} }
if (isArray(input)) { if (isArray(input)) {
this._input = input;
this.length = input.length; this.length = input.length;
this._remaining = input.length; this._remaining = input.length;
...@@ -502,28 +504,34 @@ ...@@ -502,28 +504,34 @@
fulfill(this.promise, this._result); fulfill(this.promise, this._result);
} else { } else {
this.length = this.length || 0; this.length = this.length || 0;
this._enumerate(input); this._enumerate();
if (this._remaining === 0) { if (this._remaining === 0) {
fulfill(this.promise, this._result); fulfill(this.promise, this._result);
} }
} }
} else { } else {
reject(this.promise, validationError()); _reject(this.promise, validationError());
} }
} }
Enumerator.prototype._enumerate = function _enumerate(input) { function validationError() {
for (var i = 0; this._state === PENDING && i < input.length; i++) { return new Error('Array Methods must be provided an Array');
this._eachEntry(input[i], i); };
Enumerator.prototype._enumerate = function () {
var length = this.length;
var _input = this._input;
for (var i = 0; this._state === PENDING && i < length; i++) {
this._eachEntry(_input[i], i);
} }
}; };
Enumerator.prototype._eachEntry = function _eachEntry(entry, i) { Enumerator.prototype._eachEntry = function (entry, i) {
var c = this._instanceConstructor; var c = this._instanceConstructor;
var resolve$$1 = c.resolve; var resolve$$ = c.resolve;
if (resolve$$1 === resolve$1) { if (resolve$$ === resolve) {
var _then = getThen(entry); var _then = getThen(entry);
if (_then === then && entry._state !== PENDING) { if (_then === then && entry._state !== PENDING) {
...@@ -531,29 +539,28 @@ ...@@ -531,29 +539,28 @@
} else if (typeof _then !== 'function') { } else if (typeof _then !== 'function') {
this._remaining--; this._remaining--;
this._result[i] = entry; this._result[i] = entry;
} else if (c === Promise$1) { } else if (c === Promise) {
var promise = new c(noop); var promise = new c(noop);
handleMaybeThenable(promise, entry, _then); handleMaybeThenable(promise, entry, _then);
this._willSettleAt(promise, i); this._willSettleAt(promise, i);
} else { } else {
this._willSettleAt(new c(function (resolve$$1) { this._willSettleAt(new c(function (resolve$$) {
return resolve$$1(entry); return resolve$$(entry);
}), i); }), i);
} }
} else { } else {
this._willSettleAt(resolve$$1(entry), i); this._willSettleAt(resolve$$(entry), i);
} }
}; };
Enumerator.prototype._settledAt = function _settledAt(state, i, value) { Enumerator.prototype._settledAt = function (state, i, value) {
var promise = this.promise; var promise = this.promise;
if (promise._state === PENDING) { if (promise._state === PENDING) {
this._remaining--; this._remaining--;
if (state === REJECTED) { if (state === REJECTED) {
reject(promise, value); _reject(promise, value);
} else { } else {
this._result[i] = value; this._result[i] = value;
} }
...@@ -564,7 +571,7 @@ ...@@ -564,7 +571,7 @@
} }
}; };
Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) { Enumerator.prototype._willSettleAt = function (promise, i) {
var enumerator = this; var enumerator = this;
subscribe(promise, undefined, function (value) { subscribe(promise, undefined, function (value) {
...@@ -574,9 +581,6 @@ ...@@ -574,9 +581,6 @@
}); });
}; };
return Enumerator;
}();
/** /**
`Promise.all` accepts an array of promises, and returns a new promise which `Promise.all` accepts an array of promises, and returns a new promise which
is fulfilled with an array of fulfillment values for the passed promises, or is fulfilled with an array of fulfillment values for the passed promises, or
...@@ -745,11 +749,11 @@ ...@@ -745,11 +749,11 @@
Useful for tooling. Useful for tooling.
@return {Promise} a promise rejected with the given `reason`. @return {Promise} a promise rejected with the given `reason`.
*/ */
function reject$1(reason) { function reject(reason) {
/*jshint validthis:true */ /*jshint validthis:true */
var Constructor = this; var Constructor = this;
var promise = new Constructor(noop); var promise = new Constructor(noop);
reject(promise, reason); _reject(promise, reason);
return promise; return promise;
} }
...@@ -860,12 +864,10 @@ ...@@ -860,12 +864,10 @@
``` ```
@class Promise @class Promise
@param {Function} resolver @param {function} resolver
Useful for tooling. Useful for tooling.
@constructor @constructor
*/ */
var Promise$1 = function () {
function Promise(resolver) { function Promise(resolver) {
this[PROMISE_ID] = nextId(); this[PROMISE_ID] = nextId();
this._result = this._state = undefined; this._result = this._state = undefined;
...@@ -877,10 +879,22 @@ ...@@ -877,10 +879,22 @@
} }
} }
Promise.all = all;
Promise.race = race;
Promise.resolve = resolve;
Promise.reject = reject;
Promise._setScheduler = setScheduler;
Promise._setAsap = setAsap;
Promise._asap = asap;
Promise.prototype = {
constructor: Promise,
/** /**
The primary way of interacting with a promise is through its `then` method, The primary way of interacting with a promise is through its `then` method,
which registers callbacks to receive either a promise's eventual value or the which registers callbacks to receive either a promise's eventual value or the
reason why the promise cannot be fulfilled. reason why the promise cannot be fulfilled.
```js ```js
findUser().then(function(user){ findUser().then(function(user){
// user is available // user is available
...@@ -888,11 +902,14 @@ ...@@ -888,11 +902,14 @@
// user is unavailable, and you are given the reason why // user is unavailable, and you are given the reason why
}); });
``` ```
Chaining Chaining
-------- --------
The return value of `then` is itself a promise. This second, 'downstream' The return value of `then` is itself a promise. This second, 'downstream'
promise is resolved with the return value of the first promise's fulfillment promise is resolved with the return value of the first promise's fulfillment
or rejection handler, or rejected if the handler throws an exception. or rejection handler, or rejected if the handler throws an exception.
```js ```js
findUser().then(function (user) { findUser().then(function (user) {
return user.name; return user.name;
...@@ -902,6 +919,7 @@ ...@@ -902,6 +919,7 @@
// If `findUser` fulfilled, `userName` will be the user's name, otherwise it // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
// will be `'default name'` // will be `'default name'`
}); });
findUser().then(function (user) { findUser().then(function (user) {
throw new Error('Found user, but still unhappy'); throw new Error('Found user, but still unhappy');
}, function (reason) { }, function (reason) {
...@@ -914,6 +932,7 @@ ...@@ -914,6 +932,7 @@
}); });
``` ```
If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
```js ```js
findUser().then(function (user) { findUser().then(function (user) {
throw new PedagogicalException('Upstream error'); throw new PedagogicalException('Upstream error');
...@@ -925,12 +944,15 @@ ...@@ -925,12 +944,15 @@
// The `PedgagocialException` is propagated all the way down to here // The `PedgagocialException` is propagated all the way down to here
}); });
``` ```
Assimilation Assimilation
------------ ------------
Sometimes the value you want to propagate to a downstream promise can only be Sometimes the value you want to propagate to a downstream promise can only be
retrieved asynchronously. This can be achieved by returning a promise in the retrieved asynchronously. This can be achieved by returning a promise in the
fulfillment or rejection handler. The downstream promise will then be pending fulfillment or rejection handler. The downstream promise will then be pending
until the returned promise is settled. This is called *assimilation*. until the returned promise is settled. This is called *assimilation*.
```js ```js
findUser().then(function (user) { findUser().then(function (user) {
return findCommentsByAuthor(user); return findCommentsByAuthor(user);
...@@ -938,7 +960,9 @@ ...@@ -938,7 +960,9 @@
// The user's comments are now available // The user's comments are now available
}); });
``` ```
If the assimliated promise rejects, then the downstream promise will also reject. If the assimliated promise rejects, then the downstream promise will also reject.
```js ```js
findUser().then(function (user) { findUser().then(function (user) {
return findCommentsByAuthor(user); return findCommentsByAuthor(user);
...@@ -948,11 +972,15 @@ ...@@ -948,11 +972,15 @@
// If `findCommentsByAuthor` rejects, we'll have the reason here // If `findCommentsByAuthor` rejects, we'll have the reason here
}); });
``` ```
Simple Example Simple Example
-------------- --------------
Synchronous Example Synchronous Example
```javascript ```javascript
let result; let result;
try { try {
result = findResult(); result = findResult();
// success // success
...@@ -960,7 +988,9 @@ ...@@ -960,7 +988,9 @@
// failure // failure
} }
``` ```
Errback Example Errback Example
```js ```js
findResult(function(result, err){ findResult(function(result, err){
if (err) { if (err) {
...@@ -970,7 +1000,9 @@ ...@@ -970,7 +1000,9 @@
} }
}); });
``` ```
Promise Example; Promise Example;
```javascript ```javascript
findResult().then(function(result){ findResult().then(function(result){
// success // success
...@@ -978,11 +1010,15 @@ ...@@ -978,11 +1010,15 @@
// failure // failure
}); });
``` ```
Advanced Example Advanced Example
-------------- --------------
Synchronous Example Synchronous Example
```javascript ```javascript
let author, books; let author, books;
try { try {
author = findAuthor(); author = findAuthor();
books = findBooksByAuthor(author); books = findBooksByAuthor(author);
...@@ -991,12 +1027,19 @@ ...@@ -991,12 +1027,19 @@
// failure // failure
} }
``` ```
Errback Example Errback Example
```js ```js
function foundBooks(books) { function foundBooks(books) {
} }
function failure(reason) { function failure(reason) {
} }
findAuthor(function(author, err){ findAuthor(function(author, err){
if (err) { if (err) {
failure(err); failure(err);
...@@ -1021,7 +1064,9 @@ ...@@ -1021,7 +1064,9 @@
} }
}); });
``` ```
Promise Example; Promise Example;
```javascript ```javascript
findAuthor(). findAuthor().
then(findBooksByAuthor). then(findBooksByAuthor).
...@@ -1031,116 +1076,49 @@ ...@@ -1031,116 +1076,49 @@
// something went wrong // something went wrong
}); });
``` ```
@method then @method then
@param {Function} onFulfilled @param {Function} onFulfilled
@param {Function} onRejected @param {Function} onRejected
Useful for tooling. Useful for tooling.
@return {Promise} @return {Promise}
*/ */
then: then,
/** /**
`catch` is simply sugar for `then(undefined, onRejection)` which makes it the same `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
as the catch block of a try/catch statement. as the catch block of a try/catch statement.
```js ```js
function findAuthor(){ function findAuthor(){
throw new Error('couldn't find that author'); throw new Error('couldn't find that author');
} }
// synchronous // synchronous
try { try {
findAuthor(); findAuthor();
} catch(reason) { } catch(reason) {
// something went wrong // something went wrong
} }
// async with promises // async with promises
findAuthor().catch(function(reason){ findAuthor().catch(function(reason){
// something went wrong // something went wrong
}); });
``` ```
@method catch @method catch
@param {Function} onRejection @param {Function} onRejection
Useful for tooling. Useful for tooling.
@return {Promise} @return {Promise}
*/ */
'catch': function _catch(onRejection) {
Promise.prototype.catch = function _catch(onRejection) {
return this.then(null, onRejection); return this.then(null, onRejection);
};
/**
`finally` will be invoked regardless of the promise's fate just as native
try/catch/finally behaves
Synchronous example:
```js
findAuthor() {
if (Math.random() > 0.5) {
throw new Error();
}
return new Author();
}
try {
return findAuthor(); // succeed or fail
} catch(error) {
return findOtherAuther();
} finally {
// always runs
// doesn't affect the return value
}
```
Asynchronous example:
```js
findAuthor().catch(function(reason){
return findOtherAuther();
}).finally(function(){
// author was either found, or not
});
```
@method finally
@param {Function} callback
@return {Promise}
*/
Promise.prototype.finally = function _finally(callback) {
var promise = this;
var constructor = promise.constructor;
if (isFunction(callback)) {
return promise.then(function (value) {
return constructor.resolve(callback()).then(function () {
return value;
});
}, function (reason) {
return constructor.resolve(callback()).then(function () {
throw reason;
});
});
} }
return promise.then(callback, callback);
}; };
return Promise;
}();
Promise$1.prototype.then = then;
Promise$1.all = all;
Promise$1.race = race;
Promise$1.resolve = resolve$1;
Promise$1.reject = reject$1;
Promise$1._setScheduler = setScheduler;
Promise$1._setAsap = setAsap;
Promise$1._asap = asap;
/*global self*/
function polyfill() { function polyfill() {
var local = void 0; var local = undefined;
if (typeof global !== 'undefined') { if (typeof global !== 'undefined') {
local = global; local = global;
...@@ -1169,21 +1147,18 @@ ...@@ -1169,21 +1147,18 @@
} }
} }
local.Promise = Promise$1; local.Promise = Promise;
} }
// Strange compat.. // Strange compat..
Promise$1.polyfill = polyfill; Promise.polyfill = polyfill;
Promise$1.Promise = Promise$1; Promise.Promise = Promise;
return Promise$1; return Promise;
}))); })));
}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) }).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":3}],2:[function(_dereq_,module,exports){ },{"_process":3}],2:[function(_dereq_,module,exports){
...@@ -1708,7 +1683,7 @@ ...@@ -1708,7 +1683,7 @@
wcache[key] = key; wcache[key] = key;
} }
sources[wkey] = [ sources[wkey] = [
'function(require,module,exports){' + fn + '(self); }', Function(['require','module','exports'], '(' + fn + ')(self)'),
wcache wcache
]; ];
} }
...@@ -1716,11 +1691,12 @@ ...@@ -1716,11 +1691,12 @@
var scache = {}; scache[wkey] = wkey; var scache = {}; scache[wkey] = wkey;
sources[skey] = [ sources[skey] = [
'function(require,module,exports){' + Function(['require'], (
// try to call default if defined to also support babel esmodule exports // try to call default if defined to also support babel esmodule
// exports
'var f = require(' + stringify(wkey) + ');' + 'var f = require(' + stringify(wkey) + ');' +
'(f.default ? f.default : f)(self);' + '(f.default ? f.default : f)(self);'
'}', )),
scache scache
]; ];
...@@ -1809,11 +1785,8 @@ ...@@ -1809,11 +1785,8 @@
seekParamEnd: 'bend', seekParamEnd: 'bend',
rangeLoadZeroStart: false, rangeLoadZeroStart: false,
customSeekHandler: undefined, customSeekHandler: undefined,
reuseRedirectedURL: false, reuseRedirectedURL: false
// referrerPolicy: leave as unspecified // referrerPolicy: leave as unspecified
headers: undefined,
customLoader: undefined
}; };
function createDefaultConfig() { function createDefaultConfig() {
...@@ -2477,12 +2450,7 @@ ...@@ -2477,12 +2450,7 @@
var sb = this._sourceBuffers[type]; var sb = this._sourceBuffers[type];
if (sb) { if (sb) {
if (ms.readyState !== 'closed') { if (ms.readyState !== 'closed') {
// ms edge can throw an error: Unexpected call to method or property access
try {
ms.removeSourceBuffer(sb); ms.removeSourceBuffer(sb);
} catch (error) {
_logger2.default.e(this.TAG, error.message);
}
sb.removeEventListener('error', this.e.onSourceBufferError); sb.removeEventListener('error', this.e.onSourceBufferError);
sb.removeEventListener('updateend', this.e.onSourceBufferUpdateEnd); sb.removeEventListener('updateend', this.e.onSourceBufferUpdateEnd);
} }
...@@ -3041,8 +3009,6 @@ ...@@ -3041,8 +3009,6 @@
ctl.on(_transmuxingEvents2.default.LOADING_COMPLETE, this._onLoadingComplete.bind(this)); ctl.on(_transmuxingEvents2.default.LOADING_COMPLETE, this._onLoadingComplete.bind(this));
ctl.on(_transmuxingEvents2.default.RECOVERED_EARLY_EOF, this._onRecoveredEarlyEof.bind(this)); ctl.on(_transmuxingEvents2.default.RECOVERED_EARLY_EOF, this._onRecoveredEarlyEof.bind(this));
ctl.on(_transmuxingEvents2.default.MEDIA_INFO, this._onMediaInfo.bind(this)); ctl.on(_transmuxingEvents2.default.MEDIA_INFO, this._onMediaInfo.bind(this));
ctl.on(_transmuxingEvents2.default.METADATA_ARRIVED, this._onMetaDataArrived.bind(this));
ctl.on(_transmuxingEvents2.default.SCRIPTDATA_ARRIVED, this._onScriptDataArrived.bind(this));
ctl.on(_transmuxingEvents2.default.STATISTICS_INFO, this._onStatisticsInfo.bind(this)); ctl.on(_transmuxingEvents2.default.STATISTICS_INFO, this._onStatisticsInfo.bind(this));
ctl.on(_transmuxingEvents2.default.RECOMMEND_SEEKPOINT, this._onRecommendSeekpoint.bind(this)); ctl.on(_transmuxingEvents2.default.RECOMMEND_SEEKPOINT, this._onRecommendSeekpoint.bind(this));
} }
...@@ -3172,57 +3138,39 @@ ...@@ -3172,57 +3138,39 @@
}); });
} }
}, { }, {
key: '_onMetaDataArrived',
value: function _onMetaDataArrived(metadata) {
var _this6 = this;
Promise.resolve().then(function () {
_this6._emitter.emit(_transmuxingEvents2.default.METADATA_ARRIVED, metadata);
});
}
}, {
key: '_onScriptDataArrived',
value: function _onScriptDataArrived(data) {
var _this7 = this;
Promise.resolve().then(function () {
_this7._emitter.emit(_transmuxingEvents2.default.SCRIPTDATA_ARRIVED, data);
});
}
}, {
key: '_onStatisticsInfo', key: '_onStatisticsInfo',
value: function _onStatisticsInfo(statisticsInfo) { value: function _onStatisticsInfo(statisticsInfo) {
var _this8 = this; var _this6 = this;
Promise.resolve().then(function () { Promise.resolve().then(function () {
_this8._emitter.emit(_transmuxingEvents2.default.STATISTICS_INFO, statisticsInfo); _this6._emitter.emit(_transmuxingEvents2.default.STATISTICS_INFO, statisticsInfo);
}); });
} }
}, { }, {
key: '_onIOError', key: '_onIOError',
value: function _onIOError(type, info) { value: function _onIOError(type, info) {
var _this9 = this; var _this7 = this;
Promise.resolve().then(function () { Promise.resolve().then(function () {
_this9._emitter.emit(_transmuxingEvents2.default.IO_ERROR, type, info); _this7._emitter.emit(_transmuxingEvents2.default.IO_ERROR, type, info);
}); });
} }
}, { }, {
key: '_onDemuxError', key: '_onDemuxError',
value: function _onDemuxError(type, info) { value: function _onDemuxError(type, info) {
var _this10 = this; var _this8 = this;
Promise.resolve().then(function () { Promise.resolve().then(function () {
_this10._emitter.emit(_transmuxingEvents2.default.DEMUX_ERROR, type, info); _this8._emitter.emit(_transmuxingEvents2.default.DEMUX_ERROR, type, info);
}); });
} }
}, { }, {
key: '_onRecommendSeekpoint', key: '_onRecommendSeekpoint',
value: function _onRecommendSeekpoint(milliseconds) { value: function _onRecommendSeekpoint(milliseconds) {
var _this11 = this; var _this9 = this;
Promise.resolve().then(function () { Promise.resolve().then(function () {
_this11._emitter.emit(_transmuxingEvents2.default.RECOMMEND_SEEKPOINT, milliseconds); _this9._emitter.emit(_transmuxingEvents2.default.RECOMMEND_SEEKPOINT, milliseconds);
}); });
} }
}, { }, {
...@@ -3258,8 +3206,6 @@ ...@@ -3258,8 +3206,6 @@
Object.setPrototypeOf(data, _mediaInfo2.default.prototype); Object.setPrototypeOf(data, _mediaInfo2.default.prototype);
this._emitter.emit(message.msg, data); this._emitter.emit(message.msg, data);
break; break;
case _transmuxingEvents2.default.METADATA_ARRIVED:
case _transmuxingEvents2.default.SCRIPTDATA_ARRIVED:
case _transmuxingEvents2.default.STATISTICS_INFO: case _transmuxingEvents2.default.STATISTICS_INFO:
this._emitter.emit(message.msg, data); this._emitter.emit(message.msg, data);
break; break;
...@@ -3606,8 +3552,6 @@ ...@@ -3606,8 +3552,6 @@
this._demuxer.onError = this._onDemuxException.bind(this); this._demuxer.onError = this._onDemuxException.bind(this);
this._demuxer.onMediaInfo = this._onMediaInfo.bind(this); this._demuxer.onMediaInfo = this._onMediaInfo.bind(this);
this._demuxer.onMetaDataArrived = this._onMetaDataArrived.bind(this);
this._demuxer.onScriptDataArrived = this._onScriptDataArrived.bind(this);
this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)); this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl));
...@@ -3658,16 +3602,6 @@ ...@@ -3658,16 +3602,6 @@
} }
} }
}, { }, {
key: '_onMetaDataArrived',
value: function _onMetaDataArrived(metadata) {
this._emitter.emit(_transmuxingEvents2.default.METADATA_ARRIVED, metadata);
}
}, {
key: '_onScriptDataArrived',
value: function _onScriptDataArrived(data) {
this._emitter.emit(_transmuxingEvents2.default.SCRIPTDATA_ARRIVED, data);
}
}, {
key: '_onIOSeeked', key: '_onIOSeeked',
value: function _onIOSeeked() { value: function _onIOSeeked() {
this._remuxer.insertDiscontinuity(); this._remuxer.insertDiscontinuity();
...@@ -3680,7 +3614,6 @@ ...@@ -3680,7 +3614,6 @@
if (nextSegmentIndex < this._mediaDataSource.segments.length) { if (nextSegmentIndex < this._mediaDataSource.segments.length) {
this._internalAbort(); this._internalAbort();
this._remuxer.flushStashedSamples();
this._loadSegment(nextSegmentIndex); this._loadSegment(nextSegmentIndex);
} else { } else {
this._remuxer.flushStashedSamples(); this._remuxer.flushStashedSamples();
...@@ -3826,8 +3759,6 @@ ...@@ -3826,8 +3759,6 @@
LOADING_COMPLETE: 'loading_complete', LOADING_COMPLETE: 'loading_complete',
RECOVERED_EARLY_EOF: 'recovered_early_eof', RECOVERED_EARLY_EOF: 'recovered_early_eof',
MEDIA_INFO: 'media_info', MEDIA_INFO: 'media_info',
METADATA_ARRIVED: 'metadata_arrived',
SCRIPTDATA_ARRIVED: 'scriptdata_arrived',
STATISTICS_INFO: 'statistics_info', STATISTICS_INFO: 'statistics_info',
RECOMMEND_SEEKPOINT: 'recommend_seekpoint' RECOMMEND_SEEKPOINT: 'recommend_seekpoint'
}; };
...@@ -3895,8 +3826,6 @@ ...@@ -3895,8 +3826,6 @@
controller.on(_transmuxingEvents2.default.LOADING_COMPLETE, onLoadingComplete.bind(this)); controller.on(_transmuxingEvents2.default.LOADING_COMPLETE, onLoadingComplete.bind(this));
controller.on(_transmuxingEvents2.default.RECOVERED_EARLY_EOF, onRecoveredEarlyEof.bind(this)); controller.on(_transmuxingEvents2.default.RECOVERED_EARLY_EOF, onRecoveredEarlyEof.bind(this));
controller.on(_transmuxingEvents2.default.MEDIA_INFO, onMediaInfo.bind(this)); controller.on(_transmuxingEvents2.default.MEDIA_INFO, onMediaInfo.bind(this));
controller.on(_transmuxingEvents2.default.METADATA_ARRIVED, onMetaDataArrived.bind(this));
controller.on(_transmuxingEvents2.default.SCRIPTDATA_ARRIVED, onScriptDataArrived.bind(this));
controller.on(_transmuxingEvents2.default.STATISTICS_INFO, onStatisticsInfo.bind(this)); controller.on(_transmuxingEvents2.default.STATISTICS_INFO, onStatisticsInfo.bind(this));
controller.on(_transmuxingEvents2.default.RECOMMEND_SEEKPOINT, onRecommendSeekpoint.bind(this)); controller.on(_transmuxingEvents2.default.RECOMMEND_SEEKPOINT, onRecommendSeekpoint.bind(this));
break; break;
...@@ -3981,22 +3910,6 @@ ...@@ -3981,22 +3910,6 @@
self.postMessage(obj); self.postMessage(obj);
} }
function onMetaDataArrived(metadata) {
var obj = {
msg: _transmuxingEvents2.default.METADATA_ARRIVED,
data: metadata
};
self.postMessage(obj);
}
function onScriptDataArrived(data) {
var obj = {
msg: _transmuxingEvents2.default.SCRIPTDATA_ARRIVED,
data: data
};
self.postMessage(obj);
}
function onStatisticsInfo(statInfo) { function onStatisticsInfo(statInfo) {
var obj = { var obj = {
msg: _transmuxingEvents2.default.STATISTICS_INFO, msg: _transmuxingEvents2.default.STATISTICS_INFO,
...@@ -4597,8 +4510,6 @@ ...@@ -4597,8 +4510,6 @@
this._onError = null; this._onError = null;
this._onMediaInfo = null; this._onMediaInfo = null;
this._onMetaDataArrived = null;
this._onScriptDataArrived = null;
this._onTrackMetadata = null; this._onTrackMetadata = null;
this._onDataAvailable = null; this._onDataAvailable = null;
...@@ -4668,8 +4579,6 @@ ...@@ -4668,8 +4579,6 @@
this._onError = null; this._onError = null;
this._onMediaInfo = null; this._onMediaInfo = null;
this._onMetaDataArrived = null;
this._onScriptDataArrived = null;
this._onTrackMetadata = null; this._onTrackMetadata = null;
this._onDataAvailable = null; this._onDataAvailable = null;
} }
...@@ -4829,10 +4738,6 @@ ...@@ -4829,10 +4738,6 @@
this._metadata = scriptData; this._metadata = scriptData;
var onMetaData = this._metadata.onMetaData; var onMetaData = this._metadata.onMetaData;
if (this._onMetaDataArrived) {
this._onMetaDataArrived(Object.assign({}, onMetaData));
}
if (typeof onMetaData.hasAudio === 'boolean') { if (typeof onMetaData.hasAudio === 'boolean') {
// hasAudio // hasAudio
if (this._hasAudioFlagOverrided === false) { if (this._hasAudioFlagOverrided === false) {
...@@ -4901,12 +4806,6 @@ ...@@ -4901,12 +4806,6 @@
this._onMediaInfo(this._mediaInfo); this._onMediaInfo(this._mediaInfo);
} }
} }
if (Object.keys(scriptData).length > 0) {
if (this._onScriptDataArrived) {
this._onScriptDataArrived(Object.assign({}, scriptData));
}
}
} }
}, { }, {
key: '_parseKeyframesIndex', key: '_parseKeyframesIndex',
...@@ -5598,22 +5497,6 @@ ...@@ -5598,22 +5497,6 @@
set: function set(callback) { set: function set(callback) {
this._onMediaInfo = callback; this._onMediaInfo = callback;
} }
}, {
key: 'onMetaDataArrived',
get: function get() {
return this._onMetaDataArrived;
},
set: function set(callback) {
this._onMetaDataArrived = callback;
}
}, {
key: 'onScriptDataArrived',
get: function get() {
return this._onScriptDataArrived;
},
set: function set(callback) {
this._onScriptDataArrived = callback;
}
// prototype: function(type: number, info: string): void // prototype: function(type: number, info: string): void
...@@ -6065,8 +5948,6 @@ ...@@ -6065,8 +5948,6 @@
var _features2 = _interopRequireDefault(_features); var _features2 = _interopRequireDefault(_features);
var _loader = _dereq_('./io/loader.js');
var _flvPlayer = _dereq_('./player/flv-player.js'); var _flvPlayer = _dereq_('./player/flv-player.js');
var _flvPlayer2 = _interopRequireDefault(_flvPlayer); var _flvPlayer2 = _interopRequireDefault(_flvPlayer);
...@@ -6129,10 +6010,6 @@ ...@@ -6129,10 +6010,6 @@
flvjs.isSupported = isSupported; flvjs.isSupported = isSupported;
flvjs.getFeatureList = getFeatureList; flvjs.getFeatureList = getFeatureList;
flvjs.BaseLoader = _loader.BaseLoader;
flvjs.LoaderStatus = _loader.LoaderStatus;
flvjs.LoaderErrors = _loader.LoaderErrors;
flvjs.Events = _playerEvents2.default; flvjs.Events = _playerEvents2.default;
flvjs.ErrorTypes = _playerErrors.ErrorTypes; flvjs.ErrorTypes = _playerErrors.ErrorTypes;
flvjs.ErrorDetails = _playerErrors.ErrorDetails; flvjs.ErrorDetails = _playerErrors.ErrorDetails;
...@@ -6145,13 +6022,13 @@ ...@@ -6145,13 +6022,13 @@
enumerable: true, enumerable: true,
get: function get() { get: function get() {
// replaced by browserify-versionify transform // replaced by browserify-versionify transform
return '1.5.0'; return '1.4.0';
} }
}); });
exports.default = flvjs; exports.default = flvjs;
},{"./core/features.js":6,"./io/loader.js":24,"./player/flv-player.js":32,"./player/native-player.js":33,"./player/player-errors.js":34,"./player/player-events.js":35,"./utils/exception.js":40,"./utils/logging-control.js":42,"./utils/polyfill.js":43}],21:[function(_dereq_,module,exports){ },{"./core/features.js":6,"./player/flv-player.js":32,"./player/native-player.js":33,"./player/player-errors.js":34,"./player/player-events.js":35,"./utils/exception.js":40,"./utils/logging-control.js":42,"./utils/polyfill.js":43}],21:[function(_dereq_,module,exports){
'use strict'; 'use strict';
// entry/index file // entry/index file
...@@ -6294,13 +6171,6 @@ ...@@ -6294,13 +6171,6 @@
referrerPolicy: 'no-referrer-when-downgrade' referrerPolicy: 'no-referrer-when-downgrade'
}; };
// add additional headers
if (_typeof(this._config.headers) === 'object') {
for (var _key in this._config.headers) {
headers.append(_key, this._config.headers[_key]);
}
}
// cors is enabled by default // cors is enabled by default
if (dataSource.cors === false) { if (dataSource.cors === false) {
// no-cors means 'disregard cors policy', which can only be used in ServiceWorker // no-cors means 'disregard cors policy', which can only be used in ServiceWorker
...@@ -6373,24 +6243,10 @@ ...@@ -6373,24 +6243,10 @@
// ReadableStreamReader // ReadableStreamReader
return reader.read().then(function (result) { return reader.read().then(function (result) {
if (result.done) { if (result.done) {
// First check received length
if (_this3._contentLength !== null && _this3._receivedLength < _this3._contentLength) {
// Report Early-EOF
_this3._status = _loader.LoaderStatus.kError;
var type = _loader.LoaderErrors.EARLY_EOF;
var info = { code: -1, msg: 'Fetch stream meet Early-EOF' };
if (_this3._onError) {
_this3._onError(type, info);
} else {
throw new _exception.RuntimeException(info.msg);
}
} else {
// OK. Download complete
_this3._status = _loader.LoaderStatus.kComplete; _this3._status = _loader.LoaderStatus.kComplete;
if (_this3._onComplete) { if (_this3._onComplete) {
_this3._onComplete(_this3._range.from, _this3._range.from + _this3._receivedLength - 1); _this3._onComplete(_this3._range.from, _this3._range.from + _this3._receivedLength - 1);
} }
}
} else { } else {
if (_this3._requestAbort === true) { if (_this3._requestAbort === true) {
_this3._requestAbort = false; _this3._requestAbort = false;
...@@ -6644,9 +6500,7 @@ ...@@ -6644,9 +6500,7 @@
}, { }, {
key: '_selectLoader', key: '_selectLoader',
value: function _selectLoader() { value: function _selectLoader() {
if (this._config.customLoader != null) { if (this._isWebSocketURL) {
this._loaderClass = this._config.customLoader;
} else if (this._isWebSocketURL) {
this._loaderClass = _websocketLoader2.default; this._loaderClass = _websocketLoader2.default;
} else if (_fetchStreamLoader2.default.isSupported()) { } else if (_fetchStreamLoader2.default.isSupported()) {
this._loaderClass = _fetchStreamLoader2.default; this._loaderClass = _fetchStreamLoader2.default;
...@@ -7963,17 +7817,6 @@ ...@@ -7963,17 +7817,6 @@
} }
} }
// add additional headers
if (_typeof(this._config.headers) === 'object') {
var _headers = this._config.headers;
for (var _key in _headers) {
if (_headers.hasOwnProperty(_key)) {
xhr.setRequestHeader(_key, _headers[_key]);
}
}
}
this._status = _loader.LoaderStatus.kConnecting; this._status = _loader.LoaderStatus.kConnecting;
xhr.send(); xhr.send();
} }
...@@ -8258,17 +8101,6 @@ ...@@ -8258,17 +8101,6 @@
} }
} }
// add additional headers
if (_typeof(this._config.headers) === 'object') {
var _headers = this._config.headers;
for (var _key in _headers) {
if (_headers.hasOwnProperty(_key)) {
xhr.setRequestHeader(_key, _headers[_key]);
}
}
}
if (this._isReconnecting) { if (this._isReconnecting) {
this._isReconnecting = false; this._isReconnecting = false;
} else { } else {
...@@ -8633,17 +8465,6 @@ ...@@ -8633,17 +8465,6 @@
} }
} }
// add additional headers
if (_typeof(this._config.headers) === 'object') {
var _headers = this._config.headers;
for (var _key in _headers) {
if (_headers.hasOwnProperty(_key)) {
xhr.setRequestHeader(_key, _headers[_key]);
}
}
}
xhr.send(); xhr.send();
} }
}, { }, {
...@@ -9146,12 +8967,6 @@ ...@@ -9146,12 +8967,6 @@
_this3._mediaInfo = mediaInfo; _this3._mediaInfo = mediaInfo;
_this3._emitter.emit(_playerEvents2.default.MEDIA_INFO, Object.assign({}, mediaInfo)); _this3._emitter.emit(_playerEvents2.default.MEDIA_INFO, Object.assign({}, mediaInfo));
}); });
this._transmuxer.on(_transmuxingEvents2.default.METADATA_ARRIVED, function (metadata) {
_this3._emitter.emit(_playerEvents2.default.METADATA_ARRIVED, metadata);
});
this._transmuxer.on(_transmuxingEvents2.default.SCRIPTDATA_ARRIVED, function (data) {
_this3._emitter.emit(_playerEvents2.default.SCRIPTDATA_ARRIVED, data);
});
this._transmuxer.on(_transmuxingEvents2.default.STATISTICS_INFO, function (statInfo) { this._transmuxer.on(_transmuxingEvents2.default.STATISTICS_INFO, function (statInfo) {
_this3._statisticsInfo = _this3._fillStatisticsInfo(statInfo); _this3._statisticsInfo = _this3._fillStatisticsInfo(statInfo);
_this3._emitter.emit(_playerEvents2.default.STATISTICS_INFO, Object.assign({}, _this3._statisticsInfo)); _this3._emitter.emit(_playerEvents2.default.STATISTICS_INFO, Object.assign({}, _this3._statisticsInfo));
...@@ -9921,8 +9736,6 @@ ...@@ -9921,8 +9736,6 @@
LOADING_COMPLETE: 'loading_complete', LOADING_COMPLETE: 'loading_complete',
RECOVERED_EARLY_EOF: 'recovered_early_eof', RECOVERED_EARLY_EOF: 'recovered_early_eof',
MEDIA_INFO: 'media_info', MEDIA_INFO: 'media_info',
METADATA_ARRIVED: 'metadata_arrived',
SCRIPTDATA_ARRIVED: 'scriptdata_arrived',
STATISTICS_INFO: 'statistics_info' STATISTICS_INFO: 'statistics_info'
}; };
...@@ -10956,7 +10769,7 @@ ...@@ -10956,7 +10769,7 @@
} }
}; };
silentFrames.push(frame); silentFrames.push(frame);
mdatBytes += frame.size; mdatBytes += unit.byteLength;
currentDts += refSampleDuration; currentDts += refSampleDuration;
} }
...@@ -11591,7 +11404,7 @@ ...@@ -11591,7 +11404,7 @@
} else if (console.warn) { } else if (console.warn) {
console.warn(str); console.warn(str);
} else { } else {
//console.log(str); console.log(str);
} }
} }
}, { }, {
...@@ -11612,7 +11425,7 @@ ...@@ -11612,7 +11425,7 @@
if (console.info) { if (console.info) {
console.info(str); console.info(str);
} else { } else {
//console.log(str); console.log(str);
} }
} }
}, { }, {
...@@ -11633,7 +11446,7 @@ ...@@ -11633,7 +11446,7 @@
if (console.warn) { if (console.warn) {
console.warn(str); console.warn(str);
} else { } else {
//console.log(str); console.log(str);
} }
} }
}, { }, {
...@@ -11654,7 +11467,7 @@ ...@@ -11654,7 +11467,7 @@
if (console.debug) { if (console.debug) {
console.debug(str); console.debug(str);
} else { } else {
//console.log(str); console.log(str);
} }
} }
}, { }, {
...@@ -11672,7 +11485,7 @@ ...@@ -11672,7 +11485,7 @@
return; return;
} }
//console.log(str); console.log(str);
} }
}]); }]);
......
...@@ -480,7 +480,8 @@ $(function () { ...@@ -480,7 +480,8 @@ $(function () {
var sendType=1; var sendType=1;
var guardShowOk=null; var guardShowOk=null;
var richType=1 var richType=1
var layzT=true; var layzT=true;3
$(window).on("scroll",function(){ $(window).on("scroll",function(){
if(layzT==true){ if(layzT==true){
layzT=false layzT=false
...@@ -622,6 +623,8 @@ $(function () { ...@@ -622,6 +623,8 @@ $(function () {
if (promise !== undefined) { if (promise !== undefined) {
promise.then(_ => { promise.then(_ => {
var html = []; var html = [];
html += '<div class="live-video jswebrtc" data-url="'+data.pullFlowUrl+'" ></div>';
$(".live-content-box-left-roombox").html(html)
html += '<video controls webkit-playsinline ="true" playsinline ="true" autoplay ="" playsinline="true" class="live-video" src="" id="videoElement" loop="" ></video>'; html += '<video controls webkit-playsinline ="true" playsinline ="true" autoplay ="" playsinline="true" class="live-video" src="" id="videoElement" loop="" ></video>';
$(".live-content-box-left-roombox").html(html) $(".live-content-box-left-roombox").html(html)
flvPlay(data.pullFlowUrl) flvPlay(data.pullFlowUrl)
......
...@@ -226,10 +226,10 @@ $(function(){ ...@@ -226,10 +226,10 @@ $(function(){
} }
$(".video-tag-box").html(html); $(".video-tag-box").html(html);
var html=[]; var html=[];
html+='<video autoplay="" class="video" src="" id="videoElement" controls="" loop="" poster="https://zhibocdn.yabolive.net/comm'+videoList.videos[0].cover+'"></video>'; html+='<video autoplay="" class="video" src="https://zhibocdn.yabolive.net/comm'+videoList.videos[0].url.replace("flv","mp4")+'" id="videoElement" controls="" loop="" poster="https://zhibocdn.yabolive.net/comm'+videoList.videos[0].cover+'"></video>';
$(".video-play-box").html(html) $(".video-play-box").html(html)
var flvUrl=videoList.videos[0].url.replace("mp4","flv") // var flvUrl=videoList.videos[0].url.replace("mp4","flv")
flvPlay('https://zhibocdn.yabolive.net/comm'+flvUrl+'') // flvPlay('https://zhibocdn.yabolive.net/comm'+flvUrl+'')
if(data.selfUp==1) var html='<div><img src="images/icon1.png" alt=""><span>'+data.comment+'</span></div><div class="good-box"><img class="good-btn" data-type="1" src="images/icon2-click.png" alt=""><span>'+data.up+'</span></div>'; if(data.selfUp==1) var html='<div><img src="images/icon1.png" alt=""><span>'+data.comment+'</span></div><div class="good-box"><img class="good-btn" data-type="1" src="images/icon2-click.png" alt=""><span>'+data.up+'</span></div>';
else var html='<div><img src="images/icon1.png" alt=""><span>'+data.comment+'</span></div><div class="good-box"><img class="good-btn" data-type="0" src="images/icon2.png" alt=""><span>'+data.up+'</span></div>'; else var html='<div><img src="images/icon1.png" alt=""><span>'+data.comment+'</span></div><div class="good-box"><img class="good-btn" data-type="0" src="images/icon2.png" alt=""><span>'+data.up+'</span></div>';
$(".video-btn-box").html(html) $(".video-btn-box").html(html)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment