Skip to content

Commit

Permalink
Merge pull request #1812 from vuduDASH/patch-1
Browse files Browse the repository at this point in the history
Fix try/catch for append and remove
  • Loading branch information
Dan Sparacio committed Mar 9, 2017
2 parents c406248 + b0cc2e6 commit 8f16edc
Showing 1 changed file with 14 additions and 14 deletions.
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;

0 comments on commit 8f16edc

Please sign in to comment.