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 try/catch for append and remove #1812

Merged
merged 1 commit into from
Mar 9, 2017
Merged
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
28 changes: 14 additions & 14 deletions src/streaming/controllers/SourceBufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ function SourceBufferController() {

if (!appendMethod) return;

try {
waitForUpdateEnd(buffer, function () {
waitForUpdateEnd(buffer, function () {
try {
if (acceptsChunk) {
// chunk.start is used in calculations by TextSourceBuffer
buffer[appendMethod](bytes, chunk);
Expand All @@ -292,28 +292,28 @@ function SourceBufferController() {
waitForUpdateEnd(buffer, function () {
eventBus.trigger(Events.SOURCEBUFFER_APPEND_COMPLETED, {buffer: buffer, bytes: bytes});
});
});
} catch (err) {
eventBus.trigger(Events.SOURCEBUFFER_APPEND_COMPLETED, {buffer: buffer, bytes: bytes, error: new Error(err.code, err.message, null)});
}
} catch (err) {
eventBus.trigger(Events.SOURCEBUFFER_APPEND_COMPLETED, {buffer: buffer, bytes: bytes, error: new Error(err.code, err.message, null)});
}
});
}

function remove(buffer, start, end, mediaSource) {

try {
// make sure that the given time range is correct. Otherwise we will get InvalidAccessError
waitForUpdateEnd(buffer, function () {
// make sure that the given time range is correct. Otherwise we will get InvalidAccessError
waitForUpdateEnd(buffer, function () {
try {
if ((start >= 0) && (end > start) && (mediaSource.readyState !== 'ended')) {
buffer.remove(start, end);
}
// updating is in progress, we should wait for it to complete before signaling that this operation is done
waitForUpdateEnd(buffer, function () {
eventBus.trigger(Events.SOURCEBUFFER_REMOVE_COMPLETED, {buffer: buffer, from: start, to: end});
});
});
} catch (err) {
eventBus.trigger(Events.SOURCEBUFFER_REMOVE_COMPLETED, {buffer: buffer, from: start, to: end, error: new Error(err.code, err.message, null)});
}
} catch (err) {
eventBus.trigger(Events.SOURCEBUFFER_REMOVE_COMPLETED, {buffer: buffer, from: start, to: end, error: new Error(err.code, err.message, null)});
}
});
}

function abort(mediaSource, buffer) {
Expand Down Expand Up @@ -393,4 +393,4 @@ function SourceBufferController() {
SourceBufferController.__dashjs_factory_name = 'SourceBufferController';
let factory = FactoryMaker.getSingletonFactory(SourceBufferController);
factory.QUOTA_EXCEEDED_ERROR_CODE = QUOTA_EXCEEDED_ERROR_CODE;
export default factory;
export default factory;