mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-16 16:16:40 +03:00
Fix load stream in compiled mode.
* Move retrieveGroupIds to OfflineVideoSource. * Quote properties of stored objects to avoid variable renaming issues. Issue #22 Change-Id: I31ca1261411de5ff5ae4859da571d0029ed77f42
This commit is contained in:
committed by
Gerrit Code Review
parent
176aac3bc1
commit
d414d4eaa7
@@ -137,12 +137,8 @@ app.init = function() {
|
||||
}
|
||||
|
||||
// Retrieve and verify list of offline streams
|
||||
var storage = new shaka.util.ContentDatabase(null);
|
||||
storage.setUpDatabase().then(
|
||||
function() {
|
||||
return storage.retrieveGroupIds();
|
||||
}
|
||||
).then(
|
||||
shaka.player.OfflineVideoSource.retrieveGroupIds().then(
|
||||
/** @param {!Array.<number>} groupIds */
|
||||
function(groupIds) {
|
||||
var groups = app.getOfflineGroups_();
|
||||
for (var i in groupIds) {
|
||||
@@ -154,14 +150,9 @@ app.init = function() {
|
||||
app.addOfflineStream_(value, id);
|
||||
}
|
||||
}
|
||||
).then(
|
||||
function() {
|
||||
storage.closeDatabaseConnection();
|
||||
}
|
||||
).catch(
|
||||
function(e) {
|
||||
storage.closeDatabaseConnection();
|
||||
console.error('Error retrieving stored data', e);
|
||||
console.error('Failed to retrieve group IDs', e);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -76,6 +76,34 @@ goog.inherits(shaka.player.OfflineVideoSource, shaka.player.StreamVideoSource);
|
||||
shaka.player.OfflineVideoSource.ChooseTracksCallback;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves an array of all stored group IDs.
|
||||
* @return {!Promise.<!Array.<number>>} The unique IDs of all of the
|
||||
* stored groups.
|
||||
* @export
|
||||
*/
|
||||
shaka.player.OfflineVideoSource.retrieveGroupIds = function() {
|
||||
var contentDatabase = new shaka.util.ContentDatabase(null);
|
||||
|
||||
var p = contentDatabase.setUpDatabase().then(
|
||||
function() {
|
||||
return contentDatabase.retrieveGroupIds();
|
||||
});
|
||||
|
||||
p.then(
|
||||
function() {
|
||||
contentDatabase.closeDatabaseConnection();
|
||||
}
|
||||
).catch(
|
||||
function() {
|
||||
contentDatabase.closeDatabaseConnection();
|
||||
}
|
||||
);
|
||||
|
||||
return p;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Stores the content described by the MPD for offline playback.
|
||||
* @param {string} mpdUrl The MPD URL.
|
||||
@@ -306,9 +334,10 @@ shaka.player.OfflineVideoSource.prototype.load = function(preferredLanguage) {
|
||||
/** @param {shaka.util.ContentDatabase.GroupInformation} group */
|
||||
function(group) {
|
||||
var async = [];
|
||||
this.sessionIds_ = group.session_ids;
|
||||
for (var i = 0; i < group.stream_ids.length; ++i) {
|
||||
async.push(contentDatabase.retrieveStreamIndex(group.stream_ids[i]));
|
||||
this.sessionIds_ = group['session_ids'];
|
||||
for (var i = 0; i < group['stream_ids'].length; ++i) {
|
||||
var streamId = group['stream_ids'][i];
|
||||
async.push(contentDatabase.retrieveStreamIndex(streamId));
|
||||
}
|
||||
return Promise.all(async);
|
||||
})
|
||||
@@ -352,15 +381,15 @@ shaka.player.OfflineVideoSource.prototype.reconstructManifestInfo_ =
|
||||
var storedStreamInfo = indexes[i];
|
||||
var references = [];
|
||||
|
||||
for (var j = 0; j < storedStreamInfo.references.length; j++) {
|
||||
var info = storedStreamInfo.references[j];
|
||||
for (var j = 0; j < storedStreamInfo['references'].length; j++) {
|
||||
var info = storedStreamInfo['references'][j];
|
||||
var reference = new shaka.media.SegmentReference(
|
||||
info.index,
|
||||
info.start_time,
|
||||
info.end_time,
|
||||
info.start_byte,
|
||||
info['index'],
|
||||
info['start_time'],
|
||||
info['end_time'],
|
||||
info['start_byte'],
|
||||
null,
|
||||
new goog.Uri(info.url));
|
||||
new goog.Uri(info['url']));
|
||||
references.push(reference);
|
||||
}
|
||||
|
||||
@@ -368,18 +397,18 @@ shaka.player.OfflineVideoSource.prototype.reconstructManifestInfo_ =
|
||||
var streamInfo = new shaka.media.StreamInfo();
|
||||
var segmentIndex = new shaka.media.SegmentIndex(references);
|
||||
streamInfo.segmentIndex = segmentIndex;
|
||||
streamInfo.mimeType = storedStreamInfo.mime_type;
|
||||
streamInfo.codecs = storedStreamInfo.codecs;
|
||||
streamInfo.segmentInitializationData = storedStreamInfo.init_segment;
|
||||
streamInfo.mimeType = storedStreamInfo['mime_type'];
|
||||
streamInfo.codecs = storedStreamInfo['codecs'];
|
||||
streamInfo.segmentInitializationData = storedStreamInfo['init_segment'];
|
||||
|
||||
var drmSchemeInfo = new shaka.player.DrmSchemeInfo(
|
||||
storedStreamInfo.key_system, false, '', false, null, null);
|
||||
storedStreamInfo['key_system'], false, '', false, null, null);
|
||||
var streamSetInfo = new shaka.media.StreamSetInfo();
|
||||
streamSetInfo.streamInfos.push(streamInfo);
|
||||
streamSetInfo.drmSchemes.push(drmSchemeInfo);
|
||||
streamSetInfo.contentType = streamInfo.mimeType.split('/')[0];
|
||||
periodInfo.streamSetInfos.push(streamSetInfo);
|
||||
periodInfo.duration = storedStreamInfo.duration;
|
||||
periodInfo.duration = storedStreamInfo['duration'];
|
||||
}
|
||||
manifestInfo.periodInfos.push(periodInfo);
|
||||
return manifestInfo;
|
||||
|
||||
@@ -225,7 +225,7 @@ shaka.util.ContentDatabase.SegmentInformation;
|
||||
* stream_id: number,
|
||||
* mime_type: string,
|
||||
* codecs: string,
|
||||
* duration: number,
|
||||
* duration: ?number,
|
||||
* init_segment: ArrayBuffer,
|
||||
* key_system: string,
|
||||
* references: !Array.<shaka.util.ContentDatabase.SegmentInformation>
|
||||
@@ -626,8 +626,8 @@ shaka.util.ContentDatabase.prototype.deleteGroup = function(groupId) {
|
||||
/** @param {shaka.util.ContentDatabase.GroupInformation} result */
|
||||
function(result) {
|
||||
var async = [];
|
||||
for (var id in result.stream_ids) {
|
||||
async.push(this.deleteStream(result.stream_ids[id]));
|
||||
for (var id in result['stream_ids']) {
|
||||
async.push(this.deleteStream(result['stream_ids'][id]));
|
||||
}
|
||||
var groupStore = this.getGroupStore_();
|
||||
async.push(groupStore.delete(groupId));
|
||||
|
||||
Reference in New Issue
Block a user