Various fixes for elementSource

This commit is contained in:
Jordan Eldredge 2017-11-02 21:16:46 -07:00
parent 1f9deb9c1f
commit 8a13222aa0
3 changed files with 8 additions and 7 deletions

View file

@ -109,4 +109,4 @@ Options:
* Pause a track. Resume it with pause.
* Play a track. Part way through press play again. Asserrt that the track starts over.
* While a track is loading: Press play. Nothing should happen.
* Load a large file while another file is loading. Assert that the first file stops playing while we wait.
* Load a large file while another file is playing. Assert that the first file stops playing while we wait.

View file

@ -21,6 +21,7 @@ export default class ElementSource extends Emitter {
});
this._audio.addEventListener("durationchange", () => {
this.trigger("loaded");
this._setStalled(false);
});
@ -34,7 +35,7 @@ export default class ElementSource extends Emitter {
});
this._source = this._context.createMediaElementSource(this._audio);
this._loop = true;
this._audio.loop = false;
this._source.connect(destination);
}
@ -110,11 +111,11 @@ export default class ElementSource extends Emitter {
}
getLoop() {
return this._loop;
return this._audio.loop;
}
setLoop(shouldLoop) {
this._loop = shouldLoop;
this._audio.loop = shouldLoop;
}
_setStatus(status) {

View file

@ -1,7 +1,7 @@
/* Emulate the native <audio> element with Web Audio API */
import { BANDS } from "../constants";
import BufferSource from "./bufferSource";
//import ElementSource from "./elementSource";
import ElementSource from "./elementSource";
export default class Media {
constructor(fileInput) {
@ -77,7 +77,7 @@ export default class Media {
// <destination>
this._source = new BufferSource(this._context, this._staticSource);
//this._source = new ElementSource(this._context, this._staticSource);
this._source = new ElementSource(this._context, this._staticSource);
this._source.on("positionChange", () => {
this._callbacks.timeupdate();
@ -237,8 +237,8 @@ export default class Media {
}
toggleRepeat() {
this._source.setLoop(!this._source.getLoop());
this._loop = !this._loop;
this._source.setLoop(this._loop);
}
toggleShuffle() {