mirror of
https://github.com/d07RiV/diabloweb.git
synced 2026-07-03 11:51:35 +00:00
fix safari audio
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "diabloweb",
|
"name": "diabloweb",
|
||||||
"version": "1.0.24",
|
"version": "1.0.25",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "diabloweb",
|
"name": "diabloweb",
|
||||||
"version": "1.0.24",
|
"version": "1.0.25",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "7.4.3",
|
"@babel/core": "7.4.3",
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ function no_sound() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeAudioData(context, buffer) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
context.decodeAudioData(buffer, resolve, reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default function init_sound() {
|
export default function init_sound() {
|
||||||
const AudioContext = window.AudioContext || window.webkitAudioContext;
|
const AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||||
if (!AudioContext) {
|
if (!AudioContext) {
|
||||||
@@ -29,7 +35,7 @@ export default function init_sound() {
|
|||||||
}
|
}
|
||||||
const buffer = context.createBuffer(channels, length, rate);
|
const buffer = context.createBuffer(channels, length, rate);
|
||||||
for (let i = 0; i < channels; ++i) {
|
for (let i = 0; i < channels; ++i) {
|
||||||
buffer.copyToChannel(data.subarray(i * length, i * length + length), i);
|
buffer.getChannelData(i).set(data.subarray(i * length, i * length + length));
|
||||||
}
|
}
|
||||||
sounds.set(id, {
|
sounds.set(id, {
|
||||||
buffer: Promise.resolve(buffer),
|
buffer: Promise.resolve(buffer),
|
||||||
@@ -41,7 +47,7 @@ export default function init_sound() {
|
|||||||
if (!context) {
|
if (!context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const buffer = context.decodeAudioData(data.buffer);
|
const buffer = decodeAudioData(context, data.buffer);
|
||||||
sounds.set(id, {
|
sounds.set(id, {
|
||||||
buffer,
|
buffer,
|
||||||
gain: context.createGain(),
|
gain: context.createGain(),
|
||||||
|
|||||||
Reference in New Issue
Block a user