@antha/audio 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/detect-play.js +3 -13
- package/package.json +3 -3
package/dist/detect-play.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import { DeferredPromise
|
|
1
|
+
import { DeferredPromise } from '@augment-vir/common';
|
|
2
2
|
/**
|
|
3
3
|
* Detects if the browser session currently supports playing audio.
|
|
4
4
|
*
|
|
5
5
|
* @category Internal
|
|
6
6
|
*/
|
|
7
7
|
export async function isPlayingEnabled(audioContext = new AudioContext()) {
|
|
8
|
-
/**
|
|
9
|
-
* Firefox requires an explicit resume after user gesture; other browsers auto-resume. The
|
|
10
|
-
* resume must finish before starting a source: `'ended'` never fires on a suspended context.
|
|
11
|
-
* Firefox also leaves this promise pending (rather than rejecting) while audio is still
|
|
12
|
-
* blocked, so it's raced against a timeout instead of awaited outright.
|
|
13
|
-
*/
|
|
8
|
+
/** Firefox requires an explicit resume after user gesture; other browsers auto-resume. */
|
|
14
9
|
if (audioContext instanceof AudioContext && audioContext.state === 'suspended') {
|
|
15
|
-
|
|
16
|
-
audioContext.resume().catch(() => { }),
|
|
17
|
-
wait({
|
|
18
|
-
milliseconds: 100,
|
|
19
|
-
}),
|
|
20
|
-
]);
|
|
10
|
+
audioContext.resume().catch(() => { });
|
|
21
11
|
}
|
|
22
12
|
const source = audioContext.createBufferSource();
|
|
23
13
|
source.buffer = audioContext.createBuffer(1, 1, 22_050);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/audio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "An Antha mod for handling audio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@augment-vir/common": "^32.2.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@antha/engine": "^0.
|
|
40
|
+
"@antha/engine": "^0.4.1",
|
|
41
41
|
"@augment-vir/test": "^32.2.3",
|
|
42
42
|
"@web/dev-server-esbuild": "^2.0.0",
|
|
43
43
|
"@web/test-runner": "^1.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typed-event-target": "^4.3.3"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@antha/engine": "^0.
|
|
49
|
+
"@antha/engine": "^0.4.1",
|
|
50
50
|
"element-vir": ">=26",
|
|
51
51
|
"typed-event-target": ">=4.3"
|
|
52
52
|
},
|