-
-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d935c28
commit 958e5d4
Showing
2 changed files
with
12 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
var player; | ||
var player; // Define "player" var to make my code linter happy | ||
|
||
function start() { | ||
var logs = document.getElementById('logs'); | ||
function start() { // Start Web Worker & send song data to player | ||
var logs = document.getElementById('logs'); // Define log element | ||
|
||
// Create Web Worker if it doesn't already exist | ||
if (window.Worker && typeof(player) == "undefined") { | ||
var player = new Worker("worker.js"); | ||
window.player = player; // Make variable Global | ||
player.onmessage = function(event) { | ||
var data = event.data; | ||
window.logs.value += data; | ||
}; | ||
|
||
// Send song data to player | ||
var song = document.getElementById("tones").innerHTML; | ||
player.postMessage(song); | ||
} | ||
} | ||
|
||
function end() { | ||
function end() { // Stops the Web Worker | ||
player.terminate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters