Skip to content

Commit

Permalink
fix ie 11
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Apr 12, 2021
1 parent df2c490 commit be43752
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
11 changes: 8 additions & 3 deletions src/media-segment-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ const handleSegmentBytes = ({
// for it to be audio only. See `tracks.video && tracks.audio` if statement
// above.
// we make sure to use segment.bytes here as that
dataFn(segment, {data: bytes, type: trackInfo.hasAudio && !trackInfo.isMuxed ? 'audio' : 'video'});
dataFn(segment, {
data: bytesAsUint8Array,
type: trackInfo.hasAudio && !trackInfo.isMuxed ? 'audio' : 'video'
});
if (captions && captions.length) {
captionsFn(segment, captions);
}
Expand All @@ -479,7 +482,8 @@ const handleSegmentBytes = ({
transmuxer: segment.transmuxer,
callback: ({data, startTime}) => {
// transfer bytes back to us
segment.bytes = bytesAsUint8Array = bytes = data;
bytes = data.buffer;
segment.bytes = bytesAsUint8Array = data;

if (trackInfo.hasAudio && !trackInfo.isMuxed) {
timingInfoFn(segment, 'audio', 'start', startTime);
Expand All @@ -505,7 +509,8 @@ const handleSegmentBytes = ({
trackIds: [tracks.video.id],
callback: (message) => {
// transfer bytes back to us
segment.bytes = bytesAsUint8Array = bytes = message.data;
bytes = message.data.buffer;
segment.bytes = bytesAsUint8Array = message.data;
finishLoading(message.captions);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/util/worker-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const workerCallback = function(options) {
event.data.data = new Uint8Array(
event.data.data,
options.byteOffset || 0,
options.byteLength || event.data.data.length
options.byteLength || event.data.data.byteLength
);
if (options.data) {
options.data = event.data.data;
Expand Down
60 changes: 30 additions & 30 deletions test/segment-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3074,41 +3074,41 @@ QUnit.module('SegmentLoader', function(hooks) {
const appends = [];

return setupMediaSource(loader.mediaSource_, loader.sourceUpdater_, {isVideoOnly: true}).then(() => {
const origAppendToSourceBuffer = loader.appendToSourceBuffer_.bind(loader);
return new Promise((resolve, reject) => {
loader.one('appended', resolve);
loader.one('error', reject);
const origAppendToSourceBuffer = loader.appendToSourceBuffer_.bind(loader);

loader.appendToSourceBuffer_ = (config) => {
appends.push(config);
origAppendToSourceBuffer(config);
};
loader.appendToSourceBuffer_ = (config) => {
appends.push(config);
origAppendToSourceBuffer(config);
};

const playlist = playlistWithDuration(30);
const playlist = playlistWithDuration(30);

playlist.segments[0].map = {
resolvedUri: 'init.mp4',
byterange: { length: Infinity, offset: 0 }
};
// change the map tag as we won't re-append the init segment if it hasn't changed
playlist.segments[1].map = {
resolvedUri: 'init2.mp4',
byterange: { length: 100, offset: 10 }
};
// reuse the initial map to see if it was cached
playlist.segments[2].map = {
resolvedUri: 'init.mp4',
byterange: { length: Infinity, offset: 0 }
};
playlist.segments[0].map = {
resolvedUri: 'init.mp4',
byterange: { length: Infinity, offset: 0 }
};
// change the map tag as we won't re-append the init segment if it hasn't changed
playlist.segments[1].map = {
resolvedUri: 'init2.mp4',
byterange: { length: 100, offset: 10 }
};
// reuse the initial map to see if it was cached
playlist.segments[2].map = {
resolvedUri: 'init.mp4',
byterange: { length: Infinity, offset: 0 }
};

loader.playlist(playlist);
loader.load();
this.clock.tick(1);
loader.playlist(playlist);
loader.load();
this.clock.tick(1);

// init
standardXHRResponse(this.requests.shift(), mp4VideoInitSegment());
// segment
standardXHRResponse(this.requests.shift(), mp4VideoSegment());
return new Promise((resolve, reject) => {
loader.one('appended', resolve);
loader.one('error', reject);
// init
standardXHRResponse(this.requests.shift(), mp4VideoInitSegment());
// segment
standardXHRResponse(this.requests.shift(), mp4VideoSegment());
});
}).then(() => {
this.clock.tick(1);
Expand Down

0 comments on commit be43752

Please sign in to comment.