Skip to content

Commit ff5ed6e

Browse files
committed
renaming and exposing the audio element for event handling
1 parent 99ede1c commit ff5ed6e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

speech-to-text/file-player.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function getContentType(file) {
2121
}
2222

2323
function FilePlayer(file, contentType) {
24-
var output = new Audio();
25-
if (output.canPlayType(contentType)) {
26-
output.src = URL.createObjectURL(new Blob([file], {type: contentType}));
27-
output.play();
24+
var audio = this.audio = new Audio();
25+
if (audio.canPlayType(contentType)) {
26+
audio.src = URL.createObjectURL(new Blob([file], {type: contentType}));
27+
audio.play();
2828
} else {
2929
// if we emit an error, it prevents the promise from returning the actual result
3030
// however, most browsers do not support flac, so this is a reasonably scenario
@@ -34,8 +34,8 @@ function FilePlayer(file, contentType) {
3434
throw err;
3535
}
3636
this.stop = function stop() {
37-
output.pause();
38-
output.currentTime = 0;
37+
audio.pause();
38+
audio.currentTime = 0;
3939
}
4040
}
4141

0 commit comments

Comments
 (0)