Socket
Socket
Sign inDemoInstall

shaka-player

Package Overview
Dependencies
Maintainers
1
Versions
327
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shaka-player - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

lib/polyfill/all.js

53

app.js

@@ -87,3 +87,3 @@ /**

// Display the version number.
document.getElementById('version').innerText = shaka.player.Player.version;
document.getElementById('version').textContent = shaka.player.Player.version;

@@ -164,2 +164,7 @@ // Set default values.

if ('asset' in params) {
document.getElementById('manifestUrlInput').value = params['asset'];
app.onMpdCustom();
}
if ('dash' in params) {

@@ -384,3 +389,3 @@ document.getElementById('streamTypeList').value = 'dash';

deleteButton.disabled = true;
deleteButton.innerText = 'Deleting stream...';
deleteButton.textContent = 'Deleting stream...';

@@ -403,3 +408,3 @@ var offlineList = document.getElementById('offlineStreamList');

app.removeOfflineStream_(groupId);
deleteButton.innerText = 'Delete stream from storage';
deleteButton.textContent = 'Delete stream from storage';
app.onStreamTypeChange();

@@ -411,3 +416,3 @@ app.onMpdChange();

console.error('Error deleting stream', e);
deleteButton.innerText = 'Delete stream from storage';
deleteButton.textContent = 'Delete stream from storage';
});

@@ -434,2 +439,3 @@ };

var offlineSource = new shaka.player.OfflineVideoSource(null, estimator);
offlineSource.addEventListener('progress', app.progressEventHandler_);
offlineSource.store(

@@ -456,2 +462,12 @@ mediaUrl, preferredLanguage, app.interpretContentProtection_,

/**
* Event handler for offline storage progress events.
* @param {!Event} e
* @private
*/
app.progressEventHandler_ = function(e) {
app.updateStoreButton_(true, e.detail.toFixed(2) + ' percent stored');
};
/**
* Get a map of MPD URLs to group IDs for all streams stored offline.

@@ -493,3 +509,3 @@ * @return {!Object.<number, string>}

storeButton.disabled = disabled;
storeButton.innerText = text;
storeButton.textContent = text;
};

@@ -750,3 +766,3 @@

app.videoResDebug_.innerText =
app.videoResDebug_.textContent =
app.video_.videoWidth + ' x ' + app.video_.videoHeight;

@@ -778,5 +794,3 @@ };

shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -847,5 +861,15 @@ app.polyfillsInstalled_ = true;

// This is the scheme used by YouTube's MediaSource demo.
var child = contentProtection.children[0];
var keyid = Uint8ArrayUtils.fromHex(child.getAttribute('keyid'));
var key = Uint8ArrayUtils.fromHex(child.getAttribute('key'));
var license;
for (var i = 0; i < contentProtection.children.length; ++i) {
var child = contentProtection.children[i];
if (child.nodeName == 'ytdrm:License') {
license = child;
break;
}
}
if (!license) {
return null;
}
var keyid = Uint8ArrayUtils.fromHex(license.getAttribute('keyid'));
var key = Uint8ArrayUtils.fromHex(license.getAttribute('key'));
var keyObj = {

@@ -885,4 +909,5 @@ kty: 'oct',

var child = contentProtection.children[i];
if (child.getAttribute('type') == 'widevine') {
licenseServerUrl = child.firstChild.nodeValue;
if (child.nodeName == 'yt:SystemURL' &&
child.getAttribute('type') == 'widevine') {
licenseServerUrl = child.textContent;
break;

@@ -889,0 +914,0 @@ }

@@ -0,1 +1,43 @@

## 1.3.1 (2015-05-22)
A roll-up of recent bugfixes and small improvements.
Bugfixes:
- Fixed some broken tests.
- Fixed buffering states.
- https://github.com/google/shaka-player/issues/61
- Fixed fullscreen polyfill installation.
- https://github.com/google/shaka-player/issues/81
- Fixed handling of live content with minimumUpdatePeriod of 0.
- https://github.com/google/shaka-player/pull/64
- Fixed selection of live content (type=dynamic).
- https://github.com/google/shaka-player/issues/69
- https://github.com/google/shaka-player/issues/70
- Fixed AJAX request timeouts.
- https://github.com/google/shaka-player/issues/78
- https://github.com/google/shaka-player/pull/79
- Fixed spec compliance for polyfilled session expiration.
- Fixed buffer time for offline playback.
- Fixed offline API consistency.
- https://github.com/google/shaka-player/issues/72
Features:
- Refactored and updated support test page.
- http://shaka-player-demo.appspot.com/support.html
- Simplified polyfill installation. (shaka.polyfill.installAll)
- New polyfill for CustomEvent.
- Small improvements to browser compatibility.
- (node.childNodes, node.textContent, currentScript, CSS fixes, etc.)
- Documented clock sync and CORS issues with live content.
- https://github.com/google/shaka-player/issues/53
- Documented JRE requirements.
- Test app now accepts a URL parameter to make ChromeCast testing easier.
- https://github.com/google/shaka-player/issues/56
- Stopped using deprecated methods in tests and tutorials.
- https://github.com/google/shaka-player/issues/73
- Added progress events for storing offline content.
- Documented offline APIs.
- https://github.com/google/shaka-player/issues/60
## 1.3.0 (2015-04-16)

@@ -2,0 +44,0 @@

@@ -120,9 +120,9 @@ /**

// volume
volumeBar.oninput = function() {
volumeBar.addEventListener('input', function() {
video.volume = volumeBar.value;
video.muted = false;
};
});
// volume & mute updates
video.addEventListener('volumechange', function() {
var onVolumeChange = function() {
if (video.muted) {

@@ -143,5 +143,7 @@ muteButton.style.display = 'none';

'linear-gradient(' + gradient.join(',') + ')';
});
};
video.addEventListener('volumechange', onVolumeChange);
// initialize volume display with a fake event
video.dispatchEvent(new Event('volumechange'));
onVolumeChange();

@@ -156,3 +158,3 @@ // current time & seek bar updates

// fullscreen
fullscreenButton.onclick = function() {
fullscreenButton.addEventListener('click', function() {
if (document.fullscreenElement) {

@@ -163,3 +165,3 @@ document.exitFullscreen();

}
};
});

@@ -191,3 +193,3 @@ // fullscreen updates

var bufferingSpinner = document.getElementById('bufferingSpinner');
bufferingSpinner.style.display = bufferingState ? 'flex' : 'none';
bufferingSpinner.style.display = bufferingState ? 'inherit' : 'none';
};

@@ -242,6 +244,6 @@

if ((displayTime > 1) || playerControls.isSeeking_) {
currentTime.innerText =
currentTime.textContent =
'- ' + playerControls.buildTimeString_(displayTime, showHour);
} else {
currentTime.innerText = 'LIVE';
currentTime.textContent = 'LIVE';
}

@@ -254,3 +256,3 @@

var showHour = video.duration >= 3600;
currentTime.innerText =
currentTime.textContent =
playerControls.buildTimeString_(displayTime, showHour);

@@ -257,0 +259,0 @@

@@ -81,4 +81,4 @@ /**

/** @type {?string} */
this.type = null;
/** @type {string} */
this.type = 'static';

@@ -103,3 +103,3 @@ /** @type {goog.Uri} */

* The interval, in seconds, to poll the media server for an updated
* MPD, or null if updates are not required. This value is never zero.
* MPD, or null if updates are not required.
* @type {?number}

@@ -826,3 +826,3 @@ */

this.id = mpd.parseAttr_(elem, 'id', mpd.parseString_);
this.type = mpd.parseAttr_(elem, 'type', mpd.parseString_);
this.type = mpd.parseAttr_(elem, 'type', mpd.parseString_) || 'static';
this.mediaPresentationDuration = mpd.parseAttr_(

@@ -836,3 +836,2 @@ elem, 'mediaPresentationDuration', mpd.parseDuration_);

// Disallow zero.
this.minUpdatePeriod =

@@ -842,3 +841,3 @@ mpd.parseAttr_(elem,

mpd.parseDuration_,
this.minUpdatePeriod) || null;
this.minUpdatePeriod);

@@ -1062,3 +1061,3 @@ this.availabilityStartTime =

// system.
this.children = elem.children;
this.children = Array.prototype.slice.call(elem.childNodes);
};

@@ -1384,4 +1383,4 @@

for (var i = 0; i < elem.children.length; i++) {
if (elem.children[i].tagName != name) {
for (var i = 0; i < elem.childNodes.length; i++) {
if (elem.childNodes[i].tagName != name) {
continue;

@@ -1392,3 +1391,3 @@ }

}
childElement = elem.children[i];
childElement = elem.childNodes[i];
}

@@ -1413,8 +1412,8 @@

for (var i = 0; i < elem.children.length; i++) {
if (elem.children[i].tagName != constructor.TAG_NAME) {
for (var i = 0; i < elem.childNodes.length; i++) {
if (elem.childNodes[i].tagName != constructor.TAG_NAME) {
continue;
}
var parsedChild = new constructor();
parsedChild.parse.call(parsedChild, parent, elem.children[i]);
parsedChild.parse.call(parsedChild, parent, elem.childNodes[i]);
parsedChildren.push(parsedChild);

@@ -1421,0 +1420,0 @@ }

@@ -168,3 +168,3 @@ /**

// @mediaPresentationDuration should only be used if the MPD is static.
if (isSet(mpd.minUpdatePeriod)) {
if (mpd.type != 'static') {
mpd.mediaPresentationDuration = null;

@@ -318,3 +318,3 @@ }

shaka.dash.MpdProcessor.prototype.createManifestInfo_ = function(mpd) {
this.manifestInfo.live = mpd.minUpdatePeriod != null;
this.manifestInfo.live = (mpd.type == 'dynamic');
this.manifestInfo.minBufferTime = mpd.minBufferTime ||

@@ -399,3 +399,3 @@ shaka.dash.MpdProcessor.DEFAULT_MIN_BUFFER_TIME;

// implemented.
if (mpd.minUpdatePeriod) {
if (mpd.type == 'dynamic') {
periodInfo.duration += 60 * 60 * 24 * 30;

@@ -880,3 +880,3 @@ }

var earliestAvailableTimestamp = 0;
if (mpd.minUpdatePeriod && (timeline.length > 0)) {
if (mpd.type == 'dynamic' && timeline.length > 0) {
var index = Math.max(0, timeline.length - 2);

@@ -956,3 +956,3 @@ var timeShiftBufferDepth = mpd.timeShiftBufferDepth || 0;

if (mpd.minUpdatePeriod && (references.length > 0)) {
if (mpd.type == 'dynamic' && references.length > 0) {
var minBufferTime = this.manifestInfo.minBufferTime;

@@ -1105,3 +1105,3 @@ var bestAvailableTimestamp =

var currentSegmentNumber;
if (mpd.minUpdatePeriod) {
if (mpd.type == 'dynamic') {
var pair = this.computeAvailableSegmentRange_(mpd, period, segmentTemplate);

@@ -1204,3 +1204,3 @@ if (pair) {

if (mpd.minUpdatePeriod && (references.length > 0)) {
if (mpd.type == 'dynamic' && references.length > 0) {
shaka.asserts.assert(currentSegmentNumber);

@@ -1207,0 +1207,0 @@ var scaledSegmentDuration =

@@ -72,2 +72,5 @@ /**

/** @private {shaka.dash.mpd.Mpd} mpd */
this.mpd_ = null;
/** @private {?shaka.player.DashVideoSource.ContentProtectionCallback} */

@@ -80,6 +83,6 @@ this.interpretContentProtection_ = interpretContentProtection;

/**
* The last time an MPD was fetched, in wall-clock time.
* The last time the manifest was updated, in wall-clock time.
* @private {?number}
*/
this.lastMpdFetchTime_ = null;
this.lastUpdateTime_ = null;

@@ -152,3 +155,3 @@ /** @private {shaka.util.EWMA} */

shaka.player.DashVideoSource.prototype.load = function(preferredLanguage) {
this.lastMpdFetchTime_ = Date.now() / 1000.0;
this.lastUpdateTime_ = Date.now() / 1000.0;
var mpdRequest = new shaka.dash.MpdRequest(this.mpdUrl_);

@@ -163,2 +166,3 @@

this.mpd_ = mpd;
this.timeShiftBufferDepth_ = mpd.timeShiftBufferDepth || 0;

@@ -176,3 +180,3 @@ this.manifestInfo = mpdProcessor.manifestInfo;

// least every @minimumUpdatePeriod seconds.
this.setUpdateTimer_(mpd.minUpdatePeriod || 0);
this.setUpdateTimer_();
}));

@@ -323,2 +327,3 @@ }

shaka.asserts.assert(this.manifestInfo && this.manifestInfo.live);
shaka.asserts.assert(this.mpd_);

@@ -328,20 +333,31 @@ this.cancelUpdateTimer_();

var currentTime = Date.now() / 1000.0;
this.lastUpdateTime_ = currentTime;
var secondsSinceLastUpdate = currentTime - this.lastMpdFetchTime_;
shaka.log.debug(
'Requesting new MPD... last MPD was retrieved',
secondsSinceLastUpdate,
'seconds ago.');
var p;
if (this.mpd_.minUpdatePeriod == null) {
// Do not fetch an updated MPD.
p = Promise.resolve();
} else {
// Fetch a new MPD.
var secondsSinceLastUpdate = currentTime - this.lastUpdateTime_;
shaka.log.debug(
'Requesting new MPD... last MPD was retrieved',
secondsSinceLastUpdate,
'seconds ago.');
this.lastMpdFetchTime_ = currentTime;
var mpdRequest = new shaka.dash.MpdRequest(this.mpdUrl_);
var mpdRequest = new shaka.dash.MpdRequest(this.mpdUrl_);
p = mpdRequest.send().then(shaka.util.TypedBind(this,
/** @param {!shaka.dash.mpd.Mpd} mpd */
function(mpd) {
this.mpd_ = mpd;
}));
}
mpdRequest.send().then(shaka.util.TypedBind(this,
/** @param {!shaka.dash.mpd.Mpd} mpd */
function(mpd) {
p.then(shaka.util.TypedBind(this,
function() {
shaka.asserts.assert(this.mpd_);
var mpdProcessor =
new shaka.dash.MpdProcessor(this.interpretContentProtection_);
mpdProcessor.process(mpd);
this.timeShiftBufferDepth_ = mpd.timeShiftBufferDepth || 0;
mpdProcessor.process(/** @type {!shaka.dash.mpd.Mpd} */(this.mpd_));
this.timeShiftBufferDepth_ = this.mpd_.timeShiftBufferDepth || 0;
this.updateManifest(mpdProcessor.manifestInfo);

@@ -351,3 +367,3 @@ this.evictSegmentReferences_();

this.setUpdateTimer_(mpd.minUpdatePeriod || 0);
this.setUpdateTimer_();
this.setTargetUpdateTime_();

@@ -362,3 +378,3 @@ })

// In case the application wants to ignore errors, schedule a retry.
this.setUpdateTimer_(0);
this.setUpdateTimer_();
this.setTargetUpdateTime_();

@@ -394,12 +410,11 @@ })

* Sets the update timer.
* @param {number} minUpdatePeriod
* @private
*/
shaka.player.DashVideoSource.prototype.setUpdateTimer_ = function(
minUpdatePeriod) {
shaka.player.DashVideoSource.prototype.setUpdateTimer_ = function() {
shaka.asserts.assert(this.manifestInfo && this.manifestInfo.live);
shaka.asserts.assert(this.updateTimer_ == null);
shaka.asserts.assert(this.mpd_ != null);
var updateInterval =
Math.max(minUpdatePeriod,
Math.max(this.mpd_.minUpdatePeriod || 0,
shaka.player.DashVideoSource.MIN_UPDATE_INTERVAL_);

@@ -502,5 +517,5 @@ shaka.log.debug('updateInterval', updateInterval);

(this.seekEndTime_ >= this.targetUpdateTime_)) {
var secondsSinceLastUpdate = (Date.now() / 1000.0) - this.lastMpdFetchTime_;
var secondsSinceLastUpdate = (Date.now() / 1000.0) - this.lastUpdateTime_;
// If we're not waiting for an update but we've hit our target update time,
// we must be fetching an MPD. Don't fetch another one.
// we must be processing an updating already. Don't start another one.
var waitingForUpdate = this.updateTimer_ != null;

@@ -582,3 +597,3 @@ var DashVideoSource = shaka.player.DashVideoSource;

* Should be called after a manifest is loaded or updated. Assumes that
* |lastMpdFetchTime_| is always set when an MPD request begins.
* |lastUpdateTime_| is always set when an update begins.
* @private

@@ -588,5 +603,5 @@ */

var currentTime = Date.now() / 1000.0;
var latencySample = currentTime - this.lastMpdFetchTime_;
var latencySample = currentTime - this.lastUpdateTime_;
this.latencyEstimator_.sample(1 /* weight */, latencySample);
};

@@ -41,3 +41,3 @@ /**

* in this source.
* @param {!shaka.util.IBandwidthEstimator} estimator
* @param {shaka.util.IBandwidthEstimator} estimator
* @struct

@@ -49,2 +49,8 @@ * @constructor

shaka.player.OfflineVideoSource = function(groupId, estimator) {
if (!estimator) {
// For backward compatibility, provide an instance of the default
// implementation if none is provided.
estimator = new shaka.util.EWMABandwidthEstimator();
}
shaka.player.StreamVideoSource.call(this, null, estimator);

@@ -88,3 +94,3 @@

shaka.player.OfflineVideoSource.retrieveGroupIds = function() {
var contentDatabase = new shaka.util.ContentDatabase(null);
var contentDatabase = new shaka.util.ContentDatabase(null, null);

@@ -284,27 +290,9 @@ var p = contentDatabase.setUpDatabase().then(

function(selectedStreams, drmScheme, duration) {
var streamIds = [];
var contentDatabase = new shaka.util.ContentDatabase(null);
var contentDatabase = new shaka.util.ContentDatabase(this.estimator, this);
var p = contentDatabase.setUpDatabase();
// Insert each stream into the database.
for (var i = 0; i < selectedStreams.length; ++i) {
var streamInfo = selectedStreams[i];
var insertStream = (
function(streamInfo) {
return contentDatabase.insertStream(streamInfo, duration, drmScheme);
}).bind(this, streamInfo);
p = p.then(insertStream).then(
/** @param {number} streamId */
function(streamId) {
streamIds.push(streamId);
return Promise.resolve();
});
}
// Insert information about the group of streams into the database and close
// the connection.
// Insert the group of streams into the database and close the connection.
p = p.then(shaka.util.TypedBind(this, function() {
return contentDatabase.insertGroup(streamIds, this.sessionIds_);
return contentDatabase.insertGroup(
selectedStreams, this.sessionIds_, duration, drmScheme);
})).then(

@@ -329,4 +317,5 @@ /** @param {number} groupId */

shaka.asserts.assert(this.groupId_ >= 0);
var contentDatabase = new shaka.util.ContentDatabase(null);
var contentDatabase = new shaka.util.ContentDatabase(null, null);
var p = contentDatabase.setUpDatabase();
var duration, keySystem;

@@ -343,2 +332,4 @@ return p.then(shaka.util.TypedBind(this,

this.sessionIds_ = group['session_ids'];
duration = group['duration'];
keySystem = group['key_system'];
for (var i = 0; i < group['stream_ids'].length; ++i) {

@@ -353,4 +344,4 @@ var streamId = group['stream_ids'][i];

function(indexes) {
var manifestInfo = this.reconstructManifestInfo_(indexes);
this.manifestInfo = manifestInfo;
this.manifestInfo =
this.reconstructManifestInfo_(indexes, duration, keySystem);

@@ -378,2 +369,4 @@ var baseClassLoad = shaka.player.StreamVideoSource.prototype.load;

* of the streams in this manifest.
* @param {number} duration The max stream's entire duration in the group.
* @param {string} keySystem The group's DRM key system.
* @return {!shaka.media.ManifestInfo}

@@ -383,4 +376,5 @@ * @private

shaka.player.OfflineVideoSource.prototype.reconstructManifestInfo_ =
function(indexes) {
function(indexes, duration, keySystem) {
var manifestInfo = new shaka.media.ManifestInfo();
manifestInfo.minBufferTime = 5;
// TODO(story 1890046): Support multiple periods.

@@ -414,3 +408,3 @@ var periodInfo = new shaka.media.PeriodInfo();

var drmSchemeInfo = new shaka.player.DrmSchemeInfo(
storedStreamInfo['key_system'], '', false, null, null);
keySystem, '', false, null, null);
var streamSetInfo = new shaka.media.StreamSetInfo();

@@ -421,3 +415,3 @@ streamSetInfo.streamInfos.push(streamInfo);

periodInfo.streamSetInfos.push(streamSetInfo);
periodInfo.duration = storedStreamInfo['duration'];
periodInfo.duration = duration;
}

@@ -432,6 +426,7 @@ manifestInfo.periodInfos.push(periodInfo);

* @return {!Promise}
* @export
*/
shaka.player.OfflineVideoSource.prototype.deleteGroup = function() {
shaka.asserts.assert(this.groupId_ >= 0);
var contentDatabase = new shaka.util.ContentDatabase(null);
var contentDatabase = new shaka.util.ContentDatabase(null, null);
var p = contentDatabase.setUpDatabase();

@@ -438,0 +433,0 @@ return p.then(

@@ -121,3 +121,3 @@ /**

*/
goog.define('GIT_VERSION', 'v1.3.0-debug');
goog.define('GIT_VERSION', 'v1.3.1-debug');

@@ -852,4 +852,6 @@

if (!this.buffering_) {
// Don't go into a buffering state at the end of the video.
if (fudgedBufferEnd < this.video_.duration && buffered < threshold) {
// Don't go into a buffering state while paused or when at the end of the
// video.
if ((fudgedBufferEnd < this.video_.duration && buffered < threshold) &&
!this.video_.paused) {
this.enterBufferingState_();

@@ -856,0 +858,0 @@ }

@@ -125,4 +125,4 @@ /**

/** @private {!shaka.util.IBandwidthEstimator} */
this.estimator_ = estimator;
/** @protected {!shaka.util.IBandwidthEstimator} */
this.estimator = estimator;

@@ -133,3 +133,3 @@ /** @private {shaka.player.Stats} */

/** @private {!shaka.media.AbrManager} */
this.abrManager_ = new shaka.media.AbrManager(this.estimator_, this);
this.abrManager_ = new shaka.media.AbrManager(this.estimator, this);
};

@@ -164,3 +164,3 @@ goog.inherits(shaka.player.StreamVideoSource, shaka.util.FakeEventTarget);

this.attachPromise_ = null;
this.estimator_ = null;
this.estimator = null;

@@ -191,3 +191,3 @@ this.parent = null;

this.eventManager.listen(
this.estimator_,
this.estimator,
'bandwidth',

@@ -1344,3 +1344,3 @@ this.onBandwidth_.bind(this));

/** @type {!SourceBuffer} */ (buf),
this.estimator_);
this.estimator);
};

@@ -1614,4 +1614,4 @@

shaka.asserts.assert(this.stats_);
this.stats_.logBandwidth(this.estimator_.getBandwidth());
this.stats_.logBandwidth(this.estimator.getBandwidth());
};

@@ -52,3 +52,3 @@ /**

if (!document.fullscreenElement) {
if (!('fullscreenElement' in document)) {
Object.defineProperty(document, 'fullscreenElement', {

@@ -55,0 +55,0 @@ get: function() {

@@ -409,3 +409,3 @@ /**

var isNew = isNaN(session.expiration);
var isNew = session.keyStatuses.getStatus() == undefined;

@@ -560,6 +560,2 @@ var event2 = shaka.util.FakeEvent.create({

// There is no expiration info in v0.1b, but we want to signal, at least
// internally, that the session is no longer new. This allows us to set
// the messageType attribute of 'message' events.
this.expiration = Number.POSITIVE_INFINITY;
this.updateKeyStatus_('usable');

@@ -914,2 +910,12 @@

/**
* An internal method used by the session to get key status.
* @return {string|undefined}
*/
shaka.polyfill.PatchedMediaKeys.v01b.MediaKeyStatusMap.prototype.getStatus =
function() {
return this.status_;
};
/**
* Array entry 0 is the key, 1 is the value.

@@ -916,0 +922,0 @@ * @return {Iterator.<Array.<!BufferSource|string>>}

@@ -199,2 +199,3 @@ /**

this.xhr_.onerror = null;
this.xhr_.ontimeout = null;
}

@@ -258,2 +259,3 @@ this.xhr_ = null;

this.xhr_.onerror = this.onError_.bind(this);
this.xhr_.ontimeout = this.onTimeout_.bind(this);

@@ -332,3 +334,3 @@ for (var k in this.parameters.requestHeaders) {

var db = new shaka.util.ContentDatabase(null);
var db = new shaka.util.ContentDatabase(null, null);
return db.setUpDatabase().then(

@@ -420,18 +422,3 @@ function() {

} else if (this.attempts_ < this.parameters.maxAttempts) {
this.cleanupRequest_();
var sendAgain = this.sendInternal.bind(this);
// Fuzz the delay to avoid tons of clients hitting the server at once
// after it recovers from whatever is causing it to fail.
var negToPosOne = (Math.random() * 2.0) - 1.0;
var negToPosFuzzFactor = negToPosOne * this.parameters.retryFuzzFactor;
var fuzzedDelay = this.retryDelayMs_ * (1.0 + negToPosFuzzFactor);
window.setTimeout(sendAgain, fuzzedDelay);
// Store the fuzzed delay to make testing retries feasible.
this.lastDelayMs_ = fuzzedDelay;
// Back off the next delay.
this.retryDelayMs_ *= this.parameters.retryBackoffFactor;
this.resendInternal_();
} else {

@@ -487,1 +474,42 @@ var error = this.createError_('HTTP error.', 'net');

/**
* Handles a "timeout" event.
*
* @param {!ProgressEvent} event The ProgressEvent from this.xhr_.
*
* @private
*/
shaka.util.AjaxRequest.prototype.onTimeout_ = function(event) {
if (this.attempts_ < this.parameters.maxAttempts) {
this.resendInternal_();
} else {
var error = this.createError_('Request timmedout.', 'net');
this.promise_.reject(error);
this.destroy_();
}
};
/**
* Resends request.
*
* @private
*/
shaka.util.AjaxRequest.prototype.resendInternal_ = function() {
this.cleanupRequest_();
var sendAgain = this.sendInternal.bind(this);
// Fuzz the delay to avoid tons of clients hitting the server at once
// after it recovers from whatever is causing it to fail.
var negToPosOne = (Math.random() * 2.0) - 1.0;
var negToPosFuzzFactor = negToPosOne * this.parameters.retryFuzzFactor;
var fuzzedDelay = this.retryDelayMs_ * (1.0 + negToPosFuzzFactor);
window.setTimeout(sendAgain, fuzzedDelay);
// Store the fuzzed delay to make testing retries feasible.
this.lastDelayMs_ = fuzzedDelay;
// Back off the next delay.
this.retryDelayMs_ *= this.parameters.retryBackoffFactor;
};

@@ -26,2 +26,4 @@ /**

goog.require('shaka.player.DrmSchemeInfo');
goog.require('shaka.util.FakeEvent');
goog.require('shaka.util.FakeEventTarget');
goog.require('shaka.util.IBandwidthEstimator');

@@ -33,3 +35,13 @@ goog.require('shaka.util.PublicPromise');

/**
* @event shaka.util.ContentDatabase.ProgressEvent
* @description Fired to indicate progess during the downloading and storing
* of streams.
* @property {string} type 'progress'
* @property {number} detail Percentage of group references already stored.
* @property {boolean} bubbles True
*/
/**

@@ -39,7 +51,13 @@ * Creates and manages a database for storing streams of content.

* attach to all data requests.
* @param {shaka.util.FakeEventTarget} parent The parent used for bubbling
* events.
*
* @fires shaka.util.ContentDatabase.ProgressEvent
*
* @struct
* @constructor
* @extends {shaka.util.FakeEventTarget}
*/
shaka.util.ContentDatabase = function(estimator) {
shaka.util.ContentDatabase = function(estimator, parent) {
shaka.util.FakeEventTarget.call(this, parent);

@@ -53,2 +71,3 @@ /** @private {IDBDatabase} */

};
goog.inherits(shaka.util.ContentDatabase, shaka.util.FakeEventTarget);

@@ -166,3 +185,2 @@

function(e) {
// TODO(natalieharris): Handle Success and errors using events
this.db_ = e.target.result;

@@ -210,3 +228,5 @@ p.resolve();

* references: !Array.<shaka.util.ContentDatabase.SegmentInformation>,
* firstReference: shaka.media.SegmentReference
* firstReference: shaka.media.SegmentReference,
* totalReferences: number,
* referencesInserted: number
* }}

@@ -234,5 +254,3 @@ */

* codecs: string,
* duration: ?number,
* init_segment: ArrayBuffer,
* key_system: string,
* references: !Array.<shaka.util.ContentDatabase.SegmentInformation>

@@ -248,3 +266,5 @@ * }}

* stream_ids: !Array.<number>,
* session_ids: !Array.<string>
* session_ids: !Array.<string>,
* duration: ?number,
* key_system: string
* }}

@@ -256,14 +276,61 @@ */

/**
* Inserts a group of stream ids into the database.
* @param {!Array.<number>} streamIds The IDs of the streams in this group.
* Inserts a group of streams into the database.
* @param {!Array.<!shaka.media.StreamInfo>} streamInfos The streams to insert
* as a group.
* @param {!Array.<string>} sessionIds The IDs of the MediaKeySessions for
* this group.
* @param {?number} duration The max stream's entire duration in the group.
* @param {shaka.player.DrmSchemeInfo} drmScheme The group's DRM Scheme.
* @return {!Promise.<number>} The unique id assigned to the group.
*/
shaka.util.ContentDatabase.prototype.insertGroup = function(streamIds,
sessionIds) {
return this.getNextId_(this.getGroupStore_()).then(shaka.util.TypedBind(this,
shaka.util.ContentDatabase.prototype.insertGroup = function(streamInfos,
sessionIds,
duration,
drmScheme) {
var streamIds = [];
var totalReferences = 0;
var referencesInserted = 0;
var p = Promise.resolve();
// Fetch each streams data.
for (var i = 0; i < streamInfos.length; ++i) {
var streamInfo = streamInfos[i];
var async = [
streamInfo.getSegmentIndex(),
streamInfo.getSegmentInitializationData()
];
p = p.then(
function(async) {
return Promise.all(async);
}.bind(this, async)).then(
function(streamInfo) {
totalReferences += streamInfo.segmentIndex.length();
}.bind(this, streamInfo));
}
// Insert each stream into the database.
for (var i = 0; i < streamInfos.length; ++i) {
var streamInfo = streamInfos[i];
p = /** @type {!Promise.<number>} */ (
p.then(function(streamInfo) {
return this.insertStream_(
streamInfo, totalReferences, referencesInserted);
}.bind(this, streamInfo)));
p = p.then(
/** @param {number} streamId */
function(streamInfo, streamId) {
referencesInserted += streamInfo.segmentIndex.length();
streamIds.push(streamId);
}.bind(this, streamInfo));
}
return p.then(shaka.util.TypedBind(this,
function() {
return this.getNextId_(this.getGroupStore_());
})
).then(shaka.util.TypedBind(this,
/** @param {number} groupId */
function(groupId) {
var p = new shaka.util.PublicPromise();
var groupPromise = new shaka.util.PublicPromise();

@@ -273,10 +340,12 @@ var groupInfo = {

'stream_ids': streamIds,
'session_ids': sessionIds
'session_ids': sessionIds,
'duration': duration,
'key_system': drmScheme.keySystem
};
var request = this.getGroupStore_().put(groupInfo);
request.onsuccess = function() { p.resolve(groupId); };
request.onerror = function(e) { p.reject(request.error); };
request.onsuccess = function() { groupPromise.resolve(groupId); };
request.onerror = function(e) { groupPromise.reject(request.error); };
return p;
return groupPromise;
}));

@@ -288,13 +357,11 @@ };

* Inserts a stream into the database.
* @param {shaka.media.StreamInfo} streamInfo The stream's information.
* @param {?number} duration The stream's entire duration.
* @param {shaka.player.DrmSchemeInfo} drmScheme The stream's DRM Scheme.
* @param {!shaka.media.StreamInfo} streamInfo The stream's information.
* @param {number} totalReferences Number of references in this streams group.
* @param {number} referencesInserted Number of references already inserted.
* @return {!Promise.<number>} The unique id assigned to the stream.
* @private
*/
shaka.util.ContentDatabase.prototype.insertStream = function(streamInfo,
duration,
drmScheme) {
shaka.util.ContentDatabase.prototype.insertStream_ = function(
streamInfo, totalReferences, referencesInserted) {
var async = [
streamInfo.getSegmentIndex(),
streamInfo.getSegmentInitializationData(),
this.getNextId_(this.getIndexStore_()),

@@ -305,3 +372,13 @@ this.getNextId_(this.getContentStore_().index('stream'))

var p = Promise.all(async).then(shaka.util.TypedBind(this, function(results) {
return Math.max(results[2], results[3]);
/** @type {!shaka.util.ContentDatabase.InsertStreamState} */
var state = {
streamId: Math.max(results[0], results[1]),
segment: new ArrayBuffer(0),
segmentId: 0,
references: [],
firstReference: null,
totalReferences: totalReferences,
referencesInserted: referencesInserted
};
return state;
}));

@@ -312,4 +389,3 @@ // Cast as workaround for closure compiler issue.

p = /** @type {!Promise.<number>} */ (
p.then(this.insertStreamIndex_.bind(
this, streamInfo, duration, drmScheme)));
p.then(this.insertStreamIndex_.bind(this, streamInfo)));
return p;

@@ -346,4 +422,2 @@ };

* @param {shaka.media.StreamInfo} streamInfo The stream's information.
* @param {?number} duration The stream's entire duration.
* @param {shaka.player.DrmSchemeInfo} drmScheme The stream's DRM Scheme.
* @param {!shaka.util.ContentDatabase.InsertStreamState} state The stream's

@@ -355,4 +429,2 @@ * state information.

shaka.util.ContentDatabase.prototype.insertStreamIndex_ = function(streamInfo,
duration,
drmScheme,
state) {

@@ -364,5 +436,3 @@ var p = new shaka.util.PublicPromise();

'codecs': streamInfo.codecs,
'duration': duration,
'init_segment': streamInfo.segmentInitializationData,
'key_system': drmScheme.keySystem,
'references': state.references

@@ -383,19 +453,12 @@ };

* @param {!shaka.media.StreamInfo} streamInfo The stream's information.
* @param {number} streamId The unique id of the stream inserted.
* @param {!shaka.util.ContentDatabase.InsertStreamState} state The stream's
* state information.
* @return {!Promise.<shaka.util.ContentDatabase.InsertStreamState>}
* @private
*/
shaka.util.ContentDatabase.prototype.insertStreamContent_ = function(
streamInfo, streamId) {
shaka.util.ContentDatabase.prototype.insertStreamContent_ = function(streamInfo,
state) {
var segmentIndex = streamInfo.segmentIndex;
// Initialize promise and stream insertion information to use in loop.
var segmentPromise = Promise.resolve();
/** @type {!shaka.util.ContentDatabase.InsertStreamState} */
var state = {
streamId: streamId,
segment: new ArrayBuffer(0),
segmentId: 0,
references: [],
firstReference: null
};

@@ -445,2 +508,8 @@ for (var i = 0; i < segmentIndex.length(); ++i) {

state.segment = this.concatArrayBuffers_(state.segment, segment);
state.referencesInserted++;
var percent = (state.referencesInserted / state.totalReferences) * 100;
var event = shaka.util.FakeEvent.create(
{ type: 'progress',
detail: percent,
bubbles: true });
var size = state.segment.byteLength;

@@ -467,4 +536,8 @@ if (size >= shaka.util.ContentDatabase.TARGET_SEGMENT_SIZE_ ||

request.onerror = function(e) { p.reject(request.error); };
request.onsuccess = function() { p.resolve(); };
request.onsuccess = shaka.util.TypedBind(this, function() {
this.dispatchEvent(event);
p.resolve();
});
} else {
this.dispatchEvent(event);
p.resolve();

@@ -556,3 +629,17 @@ }

shaka.util.ContentDatabase.prototype.retrieveGroup = function(groupId) {
return this.retrieveInternal_(this.getGroupStore_(), groupId);
return this.retrieveInternal_(this.getGroupStore_(), groupId).then(
/** @param {shaka.util.ContentDatabase.GroupInformation} groupInfo */
function(groupInfo) {
if (!groupInfo.hasOwnProperty('duration') &&
!groupInfo.hasOwnProperty('key_system')) {
return this.retrieveStreamIndex(groupInfo.stream_ids[0]).then(
function(index) {
groupInfo.duration = index.duration;
groupInfo.key_system = index.key_system;
return Promise.resolve(groupInfo);
});
} else {
return Promise.resolve(groupInfo);
}
}.bind(this));
};

@@ -559,0 +646,0 @@

@@ -29,3 +29,5 @@ /**

// Compute the base URL for all library sources.
var loaderSrc = document.currentScript.src;
var currentScript = document.currentScript ||
document.scripts[document.scripts.length - 1];
var loaderSrc = currentScript.src;
var baseUrl = loaderSrc.split('/').slice(0, -1).join('/') + '/';

@@ -32,0 +34,0 @@

{
"name": "shaka-player",
"description": "DASH/EME video player library",
"version": "1.3.0",
"version": "1.3.1",
"homepage": "https://github.com/google/shaka-player",

@@ -6,0 +6,0 @@ "author": "Google",

@@ -29,2 +29,9 @@ # Shaka Player #

The build scripts assume the presence of tools which are readily available on
Linux and Mac, such as bash, python, git, and java. For Windows, you can
[use cygwin][].
The Closure Compiler is built with Java JRE 7, so you must have JRE 7 or newer
in order to compile Shaka Player.
[Closure Compiler]: https://developers.google.com/closure/compiler/

@@ -34,2 +41,3 @@ [gjslint]: https://developers.google.com/closure/utilities/docs/linter_howto

[Jasmine]: http://jasmine.github.io/2.1/introduction.html
[use cygwin]: http://shaka-player-demo.appspot.com/docs/tutorial-windows.html

@@ -76,2 +84,9 @@

Compiling Shaka Player requires Java JRE 7 or greater, but you can use the
library in uncompiled mode without Java. Just generate the closure
dependencies by running:
```Shell
./build/gendeps.sh
```
[in our generated docs]: http://shaka-player-demo.appspot.com/docs/tutorial-dev.html

@@ -78,0 +93,0 @@

@@ -25,7 +25,5 @@ /**

goog.require('shaka.player.StreamVideoSource');
goog.require('shaka.polyfill.Fullscreen');
goog.require('shaka.polyfill.MediaKeys');
goog.require('shaka.polyfill.VideoPlaybackQuality');
goog.require('shaka.polyfill.installAll');
goog.require('shaka.util.EWMABandwidthEstimator');
goog.require('shaka.util.FakeEventTarget');
goog.require('shaka.util.Uint8ArrayUtils');

@@ -72,3 +72,3 @@ /**

db.setUpDatabase().then(function() {
return db.insertStream(streamInfo, 100, drmSchemeInfo);
return db.insertStream_(streamInfo, 1, 0);
}).then(function(streamId) {

@@ -75,0 +75,0 @@ db.closeDatabaseConnection();

@@ -29,3 +29,3 @@ /**

describe('ContentDatabase', function() {
var db, p, testIndex, streamInfo;
var db, p, testIndex, testReferences, streamInfo;
var originalTimeout, originalRangeRequest, originalName;

@@ -82,3 +82,3 @@

var testUrl = new goog.Uri(url);
var testReferences = [
testReferences = [
new shaka.media.SegmentReference(0, 0, 1, 0, 5, testUrl),

@@ -150,3 +150,3 @@ new shaka.media.SegmentReference(1, 1, 2, 6, 9, testUrl),

p.then(function() {
return db.insertStream(streamInfo, duration, drmScheme);
return db.insertStream_(streamInfo, testReferences.length, 0);
}).then(function(streamId) {

@@ -172,3 +172,3 @@ return db.retrieveStreamIndex(streamId);

p.then(function() {
return db.insertStream(streamInfo, duration, drmScheme);
return db.insertStream_(streamInfo, 1, 0);
}).then(function(streamId) {

@@ -181,5 +181,3 @@ return db.retrieveStreamIndex(streamId);

expect(streamIndex.mime_type).toEqual(mime);
expect(streamIndex.duration).toEqual(duration);
expect(streamIndex.init_segment).toEqual(initSegment);
expect(streamIndex.key_system).toEqual(keySystem);
done();

@@ -194,3 +192,3 @@ }).catch(function(err) {

p.then(function() {
return db.insertStream(null, duration, drmScheme);
return db.insertStream_(null, 0, 0);
}).then(function() {

@@ -208,3 +206,3 @@ fail();

p.then(function() {
return db.insertStream(streamInfo, duration, drmScheme);
return db.insertStream_(streamInfo, testReferences.length, 0);
}).then(function(data) {

@@ -226,3 +224,3 @@ streamId = data;

p.then(function() {
return db.insertStream(streamInfo, duration, drmScheme);
return db.insertStream_(streamInfo, testReferences.length, 0);
}).then(function(streamId) {

@@ -253,3 +251,3 @@ return db.retrieveSegment(streamId, 0);

p.then(function() {
return db.insertStream(streamInfo, duration, drmScheme);
return db.insertStream_(streamInfo, testReferences.length, 0);
}).then(function(streamId) {

@@ -281,3 +279,3 @@ return db.retrieveInitSegment(streamId);

p.then(function() {
return db.insertGroup([1, 2, 3], ['ABCD', 'EFG']);
return db.insertGroup([streamInfo], ['ABCD', 'EFG'], duration, drmScheme);
}).then(function(groupId) {

@@ -287,4 +285,6 @@ return db.retrieveGroup(groupId);

expect(groupInformation.group_id).toEqual(jasmine.any(Number));
expect(groupInformation.stream_ids).toEqual([1, 2, 3]);
expect(groupInformation.stream_ids.length).toEqual(1);
expect(groupInformation.session_ids).toEqual(['ABCD', 'EFG']);
expect(groupInformation.duration).toEqual(duration);
expect(groupInformation.key_system).toEqual(keySystem);
done();

@@ -303,3 +303,3 @@ }).catch(function(err) {

initalGroupIdsLength = groupIds.length;
return db.insertGroup([4, 5, 6], ['HIJK', 'LMNO']);
return db.insertGroup([streamInfo], ['HIJK'], duration, drmScheme);
}).then(function() {

@@ -317,9 +317,5 @@ return db.retrieveGroupIds();

it('deletes group information and throws error on retrieval', function(done) {
var streamIds = [];
var groupId;
p.then(function() {
return db.insertStream(streamInfo, duration, drmScheme);
}).then(function(streamId) {
streamIds.push(streamId);
return db.insertGroup(streamIds, []);
return db.insertGroup([streamInfo], [], duration, drmScheme);
}).then(function(resultingGroupId) {

@@ -340,9 +336,10 @@ groupId = resultingGroupId;

it('deletes streams in group and throws error on retrieval', function(done) {
var streamIds = [];
var streamIds, groupId;
p.then(function() {
return db.insertStream(streamInfo, duration, drmScheme);
}).then(function(streamId) {
streamIds.push(streamId);
return db.insertGroup(streamIds, []);
}).then(function(groupId) {
return db.insertGroup([streamInfo], [], duration, drmScheme);
}).then(function(id) {
groupId = id;
return db.retrieveGroup(groupId);
}).then(function(data) {
streamIds = data['stream_ids'];
return db.deleteGroup(groupId);

@@ -360,3 +357,43 @@ }).then(function() {

it('converts old format of data to new format', function(done) {
var streamId, groupId;
p.then(function() {
return db.insertGroup([streamInfo], [], duration, drmScheme);
}).then(function(currentGroupId) {
groupId = currentGroupId;
return db.retrieveGroup(currentGroupId);
}).then(function(groupInfo) {
var p = shaka.util.PublicPromise();
delete groupInfo.duration;
delete groupInfo.key_system;
streamId = groupInfo.stream_ids[0];
var groupStore = db.getGroupStore_();
var request = groupStore.put(groupInfo);
request.onsuccess = function() { p.resolve(); };
request.onerror = function(e) { p.reject(request.error); };
return p;
}).then(function() {
return db.retrieveStreamIndex(streamId);
}).then(function(streamIndex) {
var p = shaka.util.PublicPromise();
streamIndex.duration = 25;
streamIndex.key_system = 'test.key.system';
var indexStore = db.getIndexStore_();
var request = indexStore.put(streamIndex);
request.onsuccess = function() { p.resolve(); };
request.onerror = function(e) { p.reject(request.error); };
return p;
}).then(function() {
return db.retrieveGroup(groupId);
}).then(function(groupInfo) {
expect(groupInfo.duration).toEqual(25);
expect(groupInfo.key_system).toEqual('test.key.system');
done();
}).catch(function(err) {
fail(err);
done();
});
});
});

@@ -538,3 +538,4 @@ /**

// Set @minUpdatePeriod so that the MPD is treated as dynamic.
// Set @minUpdatePeriod and @type so that the MPD is treated as dynamic.
m.type = 'dynamic';
m.minUpdatePeriod = 30;

@@ -541,0 +542,0 @@

@@ -21,4 +21,3 @@ /**

goog.require('shaka.player.Player');
goog.require('shaka.polyfill.MediaKeys');
goog.require('shaka.polyfill.VideoPlaybackQuality');
goog.require('shaka.polyfill.installAll');
goog.require('shaka.util.EWMABandwidthEstimator');

@@ -52,4 +51,3 @@

// Install polyfills.
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -101,3 +99,3 @@ // Create a video tag. This will be visible so that long tests do not

player.load(newSource(plainManifest)).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -107,3 +105,3 @@ }).then(function() {

}).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -123,3 +121,3 @@ }).then(function() {

player.load(newSource(encryptedManifest)).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -129,3 +127,3 @@ }).then(function() {

}).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -147,3 +145,3 @@ }).then(function() {

player.selectVideoTrack(track.id);
player.play();
video.play();
// adapts by the time it crosses a segment boundary.

@@ -164,3 +162,3 @@ return waitForTargetTime(6.0, 10.0);

player.selectVideoTrack(track.id);
player.play();
video.play();
// adapts by the time it crosses a segment boundary.

@@ -185,29 +183,2 @@ return waitForTargetTime(6.0, 10.0);

describe('pause', function() {
it('pauses playback', function(done) {
var timestamp;
player.load(newSource(plainManifest)).then(function() {
player.play();
return waitForMovement();
}).then(function() {
expect(video.paused).toBe(false);
player.pause();
timestamp = video.currentTime;
return delay(1.0);
}).then(function() {
expect(video.paused).toBe(true);
expect(video.currentTime).toEqual(timestamp);
player.play();
return waitForMovement();
}).then(function() {
expect(video.paused).toBe(false);
expect(video.currentTime).toBeGreaterThan(timestamp);
done();
}).catch(function(error) {
fail(error);
done();
});
});
});
describe('seek', function() {

@@ -219,9 +190,9 @@ // This covers bug #18597152. Completely clearing the buffers after a seek

player.load(newSource(plainManifest)).then(function() {
player.play();
video.play();
return waitForMovement(); // gets the player out of INIT state
}).then(function() {
player.seek(40.0); // <0.1s before end of segment N (5).
video.currentTime = 40.0; // <0.1s before end of segment N (5).
return delay(2.0);
}).then(function() {
player.seek(30.0); // <0.1s before end of segment N-2 (3).
video.currentTime = 30.0; // <0.1s before end of segment N-2 (3).
return delay(5.0);

@@ -255,6 +226,6 @@ }).then(function() {

player.load(newSource(plainManifest)).then(function() {
player.play();
video.play();
return waitForMovement();
}).then(function() {
player.seek(33.0);
video.currentTime = 33.0;
return waitForMovement();

@@ -264,3 +235,3 @@ }).then(function() {

}).then(function() {
player.seek(28.0);
video.currentTime = 28.0;
// We don't expect 38.0 because of the uncertainty of network and other

@@ -294,6 +265,6 @@ // delays. This is a safe number which will not cause false failures.

const minBufferTime = 300;
this.manifestInfo.minBufferTime = minBufferTime;
var sets = this.manifestInfo.periodInfos[0].streamSetInfos;
var audioSet = sets[0].contentType == 'audio' ? sets[0] : sets[1];
expect(audioSet.contentType).toBe('audio');
audioSet.streamInfos[0].minBufferTime = minBufferTime;
// Remove the video set to speed things up.

@@ -318,3 +289,3 @@ this.manifestInfo.periodInfos[0].streamSetInfos = [audioSet];

expect(audioStreamBuffer.buffered.length).toBe(1);
player.play();
video.play();
return waitForMovement();

@@ -330,3 +301,3 @@ }).then(function() {

// Seek to the beginning, which is data we will have to re-download.
player.seek(0);
video.currentTime = 0;
// Expect to play some.

@@ -349,3 +320,3 @@ return waitForTargetTime(0.5, 2.0);

player.load(source).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -368,3 +339,3 @@ }).then(function() {

}).then(function() {
player.seek(0);
video.currentTime = 0;
return waitForMovement();

@@ -385,3 +356,3 @@ }).then(function() {

player.load(source).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -398,3 +369,3 @@ }).then(function() {

player.seek(30.0);
video.currentTime = 30.0;
return waitForTargetTime(33.0, 5.0);

@@ -415,3 +386,3 @@ }).then(function() {

player.load(source).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -523,3 +494,3 @@ }).then(function() {

player.load(newSource(plainManifest)).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -544,3 +515,3 @@ }).then(function() {

player.load(newSource(plainManifest)).then(function() {
player.play();
video.play();
return waitForTargetTime(3.0, 5.0);

@@ -567,3 +538,3 @@ }).then(function() {

player.load(newSource(plainManifest)).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -723,3 +694,3 @@ }).then(function() {

player.load(newSource(webmManifest)).then(function() {
player.play();
video.play();
return waitForMovement();

@@ -741,11 +712,40 @@ }).then(function() {

// Ignore any errors in the promise chain.
player.load(newSource(bogusManifest)).catch(function(error) {});
player.load(newSource(bogusManifest)).catch(function(error) {}).then(
function() {
// Expect the error handler to have been called.
expect(onError.calls.any()).toBe(true);
done();
});
});
// Expect the error handler to have been called.
delay(0.5).then(function() {
expect(onError.calls.any()).toBe(true);
it('respects autoplay=true', function(done) {
video.autoplay = true;
player.load(newSource(plainManifest)).then(function() {
return waitForMovement();
}).then(function() {
expect(video.currentTime).toBeGreaterThan(0.0);
expect(video.paused).toBe(false);
done();
}).catch(function(error) {
fail(error);
done();
});
});
it('respects autoplay=false', function(done) {
video.autoplay = false;
player.load(newSource(plainManifest)).then(function() {
return delay(4);
}).then(function() {
expect(video.currentTime).toBe(0);
expect(video.paused).toBe(true);
done();
}).catch(function(error) {
fail(error);
done();
});
});
// TODO(story 1970528): add tests which exercise PSSH parsing,

@@ -752,0 +752,0 @@ // SegmentTemplate resolution, and SegmentList generation.

@@ -183,5 +183,15 @@ /**

if (contentProtection.schemeIdUri == 'com.youtube.clearkey') {
var child = contentProtection.children[0];
var keyid = Uint8ArrayUtils.fromHex(child.getAttribute('keyid'));
var key = Uint8ArrayUtils.fromHex(child.getAttribute('key'));
var license;
for (var i = 0; i < contentProtection.children.length; ++i) {
var child = contentProtection.children[i];
if (child.nodeName == 'ytdrm:License') {
license = child;
break;
}
}
if (!license) {
return null;
}
var keyid = Uint8ArrayUtils.fromHex(license.getAttribute('keyid'));
var key = Uint8ArrayUtils.fromHex(license.getAttribute('key'));
var keyObj = {

@@ -188,0 +198,0 @@ kty: 'oct',

@@ -34,2 +34,4 @@ // This file was autogenerated by third_party/closure/deps/depswriter.py.

goog.addDependency('../../../lib/player/video_track.js', ['shaka.player.VideoTrack'], []);
goog.addDependency('../../../lib/polyfill/all.js', ['shaka.polyfill.installAll'], ['shaka.polyfill.CustomEvent', 'shaka.polyfill.Fullscreen', 'shaka.polyfill.MediaKeys', 'shaka.polyfill.VideoPlaybackQuality']);
goog.addDependency('../../../lib/polyfill/customevent.js', ['shaka.polyfill.CustomEvent'], []);
goog.addDependency('../../../lib/polyfill/fullscreen.js', ['shaka.polyfill.Fullscreen'], []);

@@ -43,3 +45,3 @@ goog.addDependency('../../../lib/polyfill/mediakeys.js', ['shaka.polyfill.MediaKeys'], ['shaka.log', 'shaka.polyfill.PatchedMediaKeys.nop', 'shaka.polyfill.PatchedMediaKeys.v01b']);

goog.addDependency('../../../lib/util/clock.js', ['shaka.util.Clock'], []);
goog.addDependency('../../../lib/util/content_database.js', ['shaka.util.ContentDatabase'], ['shaka.asserts', 'shaka.media.SegmentIndex', 'shaka.media.SegmentReference', 'shaka.media.StreamInfo', 'shaka.player.DrmSchemeInfo', 'shaka.util.IBandwidthEstimator', 'shaka.util.PublicPromise', 'shaka.util.RangeRequest', 'shaka.util.TypedBind']);
goog.addDependency('../../../lib/util/content_database.js', ['shaka.util.ContentDatabase'], ['shaka.asserts', 'shaka.media.SegmentIndex', 'shaka.media.SegmentReference', 'shaka.media.StreamInfo', 'shaka.player.DrmSchemeInfo', 'shaka.util.FakeEvent', 'shaka.util.FakeEventTarget', 'shaka.util.IBandwidthEstimator', 'shaka.util.PublicPromise', 'shaka.util.RangeRequest', 'shaka.util.TypedBind']);
goog.addDependency('../../../lib/util/data_view_reader.js', ['shaka.util.DataViewReader'], ['shaka.asserts']);

@@ -46,0 +48,0 @@ goog.addDependency('../../../lib/util/ebml_parser.js', ['shaka.util.EbmlElement', 'shaka.util.EbmlParser'], []);

@@ -20,5 +20,3 @@ <!DOCTYPE html>

// Install polyfills.
shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -25,0 +23,0 @@ // Find the video element.

@@ -21,5 +21,3 @@ <!DOCTYPE html>

// Install polyfills.
shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -26,0 +24,0 @@ // Find the video element.

@@ -21,5 +21,3 @@ <!DOCTYPE html>

// Install polyfills.
shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -63,3 +61,3 @@ // Find the video element.

var li = document.createElement('li');
li.innerText = text;
li.textContent = text;
ul.appendChild(li);

@@ -77,3 +75,3 @@ }

// Begin playback, since autoplay is not enabled on the video tag.
player.play();
video.play();
});

@@ -80,0 +78,0 @@ }

@@ -20,5 +20,3 @@ <!DOCTYPE html>

// Install polyfills.
shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -25,0 +23,0 @@ // Find the video element.

@@ -143,5 +143,3 @@ <!DOCTYPE html>

// Install polyfills.
shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -148,0 +146,0 @@ // Get the video element.

@@ -166,5 +166,3 @@ <!DOCTYPE html>

// Install polyfills.
shaka.polyfill.Fullscreen.install();
shaka.polyfill.MediaKeys.install();
shaka.polyfill.VideoPlaybackQuality.install();
shaka.polyfill.installAll();

@@ -171,0 +169,0 @@ // Get important elements.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc