@euterpe.js/player
Advanced tools
Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "@euterpe.js/player", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A simple, safe AudioContext web music player", |
@@ -121,3 +121,3 @@ var _MusicPlayer_instances, _MusicPlayer_volume_cache, _MusicPlayer_pub_sub, _MusicPlayer_emit_time, _MusicPlayer_emit_duration_fmt, _MusicPlayer_emit_time_fmt, _MusicPlayerBuilder_audio_context, _MusicPlayerBuilder_gain, _MusicPlayerBuilder_track, _MusicPlayerBuilder_volume, _MusicPlayerBuilder_prev_node, _MusicPlayerBuilder_is_gain_connected; | ||
return new Promise((resolve, reject) => { | ||
if (this.track.context.state == "closed" || this.track.context.state == "suspended") { | ||
if (this.track.context.state !== "running") { | ||
this.is_playing = false; | ||
@@ -141,4 +141,4 @@ reject(new Error("Can't seek - track not playing")); | ||
return new Promise((resolve, reject) => { | ||
if (this.audio_context.state === "suspended" || this.audio_context.state === "closed") { | ||
this.audio_context.resume().then(undefined, (e) => reject(new Error("Context closed or suspended" + JSON.stringify(e)))); | ||
if (this.track.context.state !== "running") { | ||
this.audio_context.resume().then(undefined, (e) => reject(e)); | ||
} | ||
@@ -151,3 +151,3 @@ if (this.audio_element.paused) { | ||
this.is_playing = false; | ||
reject(new Error("failed to play audio elements" + JSON.stringify(r))); | ||
reject(r); | ||
}); | ||
@@ -167,3 +167,3 @@ } | ||
return new Promise((resolve, reject) => { | ||
if (this.audio_context.state === "suspended" || this.audio_context.state === "closed") { | ||
if (this.track.context.state !== "running") { | ||
this.audio_context.resume(); | ||
@@ -177,3 +177,3 @@ } | ||
this.is_playing = false; | ||
reject(new Error(JSON.stringify(r))); | ||
reject(r); | ||
}); | ||
@@ -211,3 +211,3 @@ } | ||
resolve(Error("Already playing")); | ||
if (this.audio_context.state === "suspended" || this.audio_context.state === "closed") { | ||
if (this.track.context.state !== "running") { | ||
this.audio_context.resume().then(() => { | ||
@@ -219,3 +219,3 @@ this.audio_element.play().then((s) => { | ||
this.is_playing = false; | ||
reject(new Error(JSON.stringify(r))); | ||
reject(r); | ||
}); | ||
@@ -230,3 +230,3 @@ }, (e) => reject(new Error("Context closed or suspended" + JSON.stringify(e)))); | ||
this.is_playing = false; | ||
reject(new Error(JSON.stringify(r))); | ||
reject(r); | ||
}); | ||
@@ -248,3 +248,3 @@ } | ||
this.is_playing = false; | ||
reject(new Error(JSON.stringify(r))); | ||
reject(r); | ||
}); | ||
@@ -261,3 +261,3 @@ }); | ||
this.is_playing = false; | ||
throw new Error(r); | ||
throw r; | ||
}); | ||
@@ -286,7 +286,7 @@ } | ||
controller.abort(); | ||
reject(new Error("Failed to load new song, error:" + JSON.stringify(e))); | ||
reject(e); | ||
}, { signal: controller.signal }); | ||
this.audio_element.addEventListener("stalled", function stalled_listener(e) { | ||
controller.abort(); | ||
reject(new Error("Failed to load new song, stalled: " + JSON.stringify(e))); | ||
reject(e); | ||
}, { signal: controller.signal }); | ||
@@ -418,3 +418,3 @@ //once aborted, try to set current_song_duration | ||
// ↓ For old browsers | ||
const AudioContext = window.AudioContext || window.webkitAudioContext; | ||
const AudioContext = window.AudioContext; | ||
__classPrivateFieldSet(this, _MusicPlayerBuilder_audio_context, new AudioContext(), "f"); | ||
@@ -421,0 +421,0 @@ __classPrivateFieldSet(this, _MusicPlayerBuilder_track, __classPrivateFieldGet(this, _MusicPlayerBuilder_audio_context, "f").createMediaElementSource(audio_element), "f"); |
Sorry, the diff of this file is not supported yet
44912