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

use webwackify for webworkers to support webpack bundle #50

Merged
merged 3 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -96,7 +96,7 @@
"mux.js": "4.3.2",
"url-toolkit": "^2.1.3",
"video.js": "^6.2.0",
"webworkify": "^1.5.0"
"webwackify": "0.1.3"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down
14 changes: 12 additions & 2 deletions src/master-playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as Ranges from './ranges';
import videojs from 'video.js';
import AdCueTags from './ad-cue-tags';
import SyncController from './sync-controller';
import worker from 'webworkify';
import worker from 'webwackify';
import Decrypter from './decrypter-worker';
import Config from './config';
import {
Expand Down Expand Up @@ -40,6 +40,16 @@ const sumLoaderStat = function(stat) {
this.mainSegmentLoader_[stat];
};

const workerResolve = () => {
let result;

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

return result;
};

/**
* the master playlist controller controller all interactons
* between playlists and segmentloaders. At this time this mainly
Expand Down Expand Up @@ -105,7 +115,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
label: 'segment-metadata'
}, false).track;

this.decrypter_ = worker(Decrypter);
this.decrypter_ = worker(Decrypter, workerResolve());

const segmentLoaderSettings = {
hls: this.hls_,
Expand Down
14 changes: 12 additions & 2 deletions src/mse/virtual-source-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ 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 workerResolve = () => {
let result;

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

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 +207,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, workerResolve());
this.transmuxer_.postMessage({action: 'init', options });

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