Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(offline): Text segments are downloaded before audio&video #7336

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,8 @@ shaka.extern.LcevcConfiguration;
* <br>
* Defaults to <code>true</code>.
* @property {number} numberOfParallelDownloads
* Number of parallel downloads.
* Number of parallel downloads. If the value is 0, downloads will be
* sequential for each stream.
* Note: normally browsers limit to 5 request in parallel, so putting a
* number higher than this will not help it download faster.
* <br>
Expand Down
22 changes: 12 additions & 10 deletions lib/offline/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ shaka.offline.Storage = class {
manifest.presentationTimeline.getSegmentAvailabilityStart();

const numberOfParallelDownloads = config.offline.numberOfParallelDownloads;
let groupId = 0;
let groupId = numberOfParallelDownloads === 0 ? stream.id : 0;

shaka.offline.Storage.forEachSegment_(stream, startTime, (segment) => {
const pendingSegmentRefId =
Expand Down Expand Up @@ -1666,7 +1666,9 @@ shaka.offline.Storage = class {
thumbnailSprite: segment.thumbnailSprite,
};
streamDb.segments.push(segmentDB);
groupId = (groupId + 1) % numberOfParallelDownloads;
if (numberOfParallelDownloads !== 0) {
groupId = (groupId + 1) % numberOfParallelDownloads;
}
});

return streamDb;
Expand Down Expand Up @@ -1861,14 +1863,6 @@ shaka.offline.Storage = class {
/** @type {!Set.<shaka.extern.Stream>} */
const set = new Set();

for (const text of manifest.textStreams) {
set.add(text);
}

for (const image of manifest.imageStreams) {
set.add(image);
}

for (const variant of manifest.variants) {
if (variant.audio) {
set.add(variant.audio);
Expand All @@ -1878,6 +1872,14 @@ shaka.offline.Storage = class {
}
}

for (const text of manifest.textStreams) {
set.add(text);
}

for (const image of manifest.imageStreams) {
set.add(image);
}

return set;
}

Expand Down
Loading