Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

use webwackify for webworkers to support webpack bundle #173

Merged
merged 1 commit into from
Mar 6, 2018
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"global": "^4.3.0",
"mux.js": "4.3.2",
"video.js": "^5.17.0 || ^6.2.0",
"webworkify": "1.0.2"
"webwackify": "0.1.3"
},
"devDependencies": {
"babel": "^5.8.0",
Expand Down
16 changes: 14 additions & 2 deletions src/flash-source-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@ import removeCuesFromTrack from './remove-cues-from-track';
import createTextTracksIfNecessary from './create-text-tracks-if-necessary';
import {addTextTrackData} from './add-text-track-data';
import transmuxWorker from './flash-transmuxer-worker';
import work from 'webworkify';
import work from 'webwackify';
import FlashConstants from './flash-constants';

const resolveFlashTransmuxWorker = () => {
let result;

try {
result = require.resolve('./flash-transmuxer-worker');
} catch (e) {
// no result
}

return result;
};

/**
* A wrapper around the setTimeout function that uses
* the flash constant time between ticks value.
Expand Down Expand Up @@ -125,7 +137,7 @@ export default class FlashSourceBuffer extends videojs.EventTarget {

this.mediaSource_.swfObj.vjs_appendChunkReady(this.flashEncodedHeaderName_);

this.transmuxer_ = work(transmuxWorker);
this.transmuxer_ = work(transmuxWorker, resolveFlashTransmuxWorker());
this.transmuxer_.postMessage({ action: 'init', options: {} });
this.transmuxer_.onmessage = (event) => {
if (event.data.action === 'data') {
Expand Down
16 changes: 14 additions & 2 deletions src/virtual-source-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ import videojs from 'video.js';
import createTextTracksIfNecessary from './create-text-tracks-if-necessary';
import removeCuesFromTrack from './remove-cues-from-track';
import {addTextTrackData} from './add-text-track-data';
import work from 'webworkify';
import work from 'webwackify';
import transmuxWorker from './transmuxer-worker';
import {isAudioCodec, isVideoCodec} from './codec-utils';

const resolveTransmuxWorker = () => {
let result;

try {
result = require.resolve('./transmuxer-worker');
} catch (e) {
// no result
}

return result;
};

// We create a wrapper around the SourceBuffer so that we can manage the
// state of the `updating` property manually. We have to do this because
// Firefox changes `updating` to false long before triggering `updateend`
Expand Down Expand Up @@ -197,7 +209,7 @@ export default class VirtualSourceBuffer extends videojs.EventTarget {

// append muxed segments to their respective native buffers as
// soon as they are available
this.transmuxer_ = work(transmuxWorker);
this.transmuxer_ = work(transmuxWorker, resolveTransmuxWorker());
this.transmuxer_.postMessage({action: 'init', options });

this.transmuxer_.onmessage = (event) => {
Expand Down