mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-06 02:00:46 +00:00
35 lines
613 B
TypeScript
35 lines
613 B
TypeScript
// Copyright (c) 2016 Brandon Thomas <bt@brand.io, echelon@gmail.com>
|
|
|
|
declare var buzz: any; // TODO: static types.
|
|
|
|
import { talk, stopTalking } from "./animation";
|
|
|
|
export default class Audio {
|
|
sound: any;
|
|
|
|
constructor() {
|
|
this.sound = null;
|
|
}
|
|
|
|
playUrl(url: string) {
|
|
this.stop();
|
|
this.sound = new buzz.sound(url);
|
|
this.sound.play();
|
|
|
|
this.sound.bind('play playing', function() {
|
|
talk(); // UI
|
|
});
|
|
|
|
this.sound.bind('error ended pause', function() {
|
|
stopTalking(); // UI
|
|
});
|
|
}
|
|
|
|
stop() {
|
|
if (this.sound != null) {
|
|
this.sound.stop();
|
|
}
|
|
}
|
|
}
|
|
|