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

Add enableWorker option. #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
</label>
</p>
<p>
<label for="cbEnableWorker">
hls.js enableWorker:
<input type="checkbox" id="cbEnableWorker">
</label>
</p>
<p>
<label for="cbNative">
Maintain original video size:
<input type="checkbox" id="cbNative">
Expand Down
6 changes: 5 additions & 1 deletion options.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
function save_options() {
var v = document.getElementById('hlsjsSel').value;
var dbg = document.getElementById('cbDebug').checked;
var enableWorker = document.getElementById('cbEnableWorker').checked;
var ntv = document.getElementById('cbNative').checked;
chrome.storage.local.set({
hlsjs: v,
debug: dbg,
enableWorker: enableWorker,
native_video: ntv
}, function() {
var status = document.getElementById('status');
Expand All @@ -19,10 +21,12 @@ function restore_options() {
chrome.storage.local.get({
hlsjs: currentVersion,
debug: false,
enableWorker: true,
native_video: false
}, function(items) {
document.getElementById('hlsjsSel').value = items.hlsjs;
document.getElementById('cbDebug').checked = items.debug;
document.getElementById('cbEnableWorker').checked = items.enableWorker;
document.getElementById('cbNative').checked = items.native_video;
});
}
Expand All @@ -34,4 +38,4 @@ for (var i in supportedVersions) {
var opt = document.createElement("option");
opt.innerHTML = supportedVersions[i];
document.getElementById('hlsjsSel').appendChild(opt)
}
}
8 changes: 5 additions & 3 deletions player.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var hls;
var debug;
var debug, enableWorker;
var recoverDecodingErrorDate,recoverSwapAudioCodecDate;
var pendingTimedMetadata = [];

Expand Down Expand Up @@ -51,7 +51,7 @@ function playM3u8(url){
video.classList.add("zoomed_mode");
}
if(hls){ hls.destroy(); }
hls = new Hls({debug:debug});
hls = new Hls({debug:debug, enableWorker: enableWorker});
hls.on(Hls.Events.ERROR, function(event,data) {
var msg = "Player error: " + data.type + " - " + data.details;
console.error(msg);
Expand Down Expand Up @@ -84,9 +84,11 @@ function playM3u8(url){
chrome.storage.local.get({
hlsjs: currentVersion,
debug: false,
enableWorker: true,
native: false
}, function(settings) {
debug = settings.debug;
enableWorker = settings.enableWorker;
native = settings.native;
var s = document.createElement('script');
var version = currentVersion
Expand All @@ -100,4 +102,4 @@ chrome.storage.local.get({

$(window).bind('hashchange', function() {
playM3u8(window.location.href.split("#")[1]);
});
});