Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix playback for ios 17.4 #1

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"repository": {
"type": "git",
"url": "git://github.com/goldfire/howler.js.git"
"url": "git://github.com/catalogworks/howler.js.git"
},
"main": "dist/howler.js",
"license": "MIT",
Expand All @@ -32,4 +32,4 @@
"tests",
"examples"
]
}
}
4 changes: 2 additions & 2 deletions dist/howler.core.min.js

Large diffs are not rendered by default.

36 changes: 33 additions & 3 deletions dist/howler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* howler.js v2.2.4
* howler.js v2.2.5
* howlerjs.com
*
* (c) 2013-2020, James Simpson of GoldFire Studios
Expand Down Expand Up @@ -993,6 +993,12 @@
};
node.addEventListener(Howler._canPlayEvent, listener, false);

// (IOS 17.4 PATCH)
// the node is not actually playing (has received suspend event and NETWORK_IDLE)
if (node.networkState === 1 && node._wasSuspended) {
node.play();
}

// Cancel the end timer.
self._clearTimer(sound._id);
}
Expand Down Expand Up @@ -1763,6 +1769,10 @@
// Remove any event listeners.
sounds[i]._node.removeEventListener('error', sounds[i]._errorFn, false);
sounds[i]._node.removeEventListener(Howler._canPlayEvent, sounds[i]._loadFn, false);
// IOS17.4 PATCH
sounds[i]._node.removeEventListener('loadedmetadata', sounds[i]._loadFn, false);
sounds[i]._node.removeEventListener('suspend', setAudioNodeWasSuspendedFromEvent, false);

sounds[i]._node.removeEventListener('ended', sounds[i]._endFn, false);

// Release the Audio object back to the pool.
Expand Down Expand Up @@ -2264,6 +2274,12 @@
self._loadFn = self._loadListener.bind(self);
self._node.addEventListener(Howler._canPlayEvent, self._loadFn, false);

// IOS17.4 PATCH
// cancplaythrough may not fire if the audio node is suspended
// ensure event queue is started here
// may have side effects beyond the _wasSuspended
self._node.addEventListener('loadedmetadata', self._loadFn, false);

// Listen for the 'ended' event on the sound to account for edge-case where
// a finite sound has a duration of Infinity.
self._endFn = self._endListener.bind(self);
Expand All @@ -2274,6 +2290,12 @@
self._node.preload = parent._preload === true ? 'auto' : parent._preload;
self._node.volume = volume * Howler.volume();

// IOS 17.4 PATCH
// record suspended event with dirty param for later mitigation
self._node._wasSuspended = false;
self._node.addEventListener('suspend', setAudioNodeWasSuspendedFromEvent, false);


// Begin loading the source.
self._node.load();
}
Expand Down Expand Up @@ -2340,8 +2362,10 @@
parent._loadQueue();
}

// Clear the event listener.
// Clear the event listener(s).
// IOS 17.4 PATCH
self._node.removeEventListener(Howler._canPlayEvent, self._loadFn, false);
self._node.removeEventListener('loadedmetadata', self._loadFn, false);
},

/**
Expand Down Expand Up @@ -2506,6 +2530,12 @@
}
};


// IOS17.4 PATCH
var setAudioNodeWasSuspendedFromEvent = function(event) {
event.target._wasSuspended = true;
}

/**
* Setup the audio context when available, or switch to HTML5 Audio mode.
*/
Expand Down Expand Up @@ -2590,7 +2620,7 @@
/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.2.4
* howler.js v2.2.5
* howlerjs.com
*
* (c) 2013-2020, James Simpson of GoldFire Studios
Expand Down
4 changes: 2 additions & 2 deletions dist/howler.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/howler.spatial.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "howler",
"version": "2.2.4",
"version": "2.2.5",
"description": "Javascript audio library for the modern web.",
"homepage": "https://howlerjs.com",
"keywords": [
Expand All @@ -16,10 +16,10 @@
"audio sprite",
"audiosprite"
],
"author": "James Simpson <[email protected]> (http://goldfirestudios.com)",
"author": "@catalogworks",
"repository": {
"type": "git",
"url": "git://github.com/goldfire/howler.js.git"
"url": "git://github.com/catalogworks/howler.js.git"
},
"scripts": {
"build": "VERSION=`printf 'v' && node -e 'console.log(require(\"./package.json\").version)'` && sed -i '' '2s/.*/ * howler.js '\"$VERSION\"'/' src/howler.core.js && sed -i '' '4s/.*/ * howler.js '\"$VERSION\"'/' src/plugins/howler.spatial.js && uglifyjs --preamble \"/*! howler.js $VERSION | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */\" src/howler.core.js -c -m --screw-ie8 -o dist/howler.core.min.js && uglifyjs --preamble \"/*! howler.js $VERSION | Spatial Plugin | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */\" src/plugins/howler.spatial.js -c -m --screw-ie8 -o dist/howler.spatial.min.js && awk 'FNR==1{echo \"\"}1' dist/howler.core.min.js dist/howler.spatial.min.js | sed '3s~.*~/*! Spatial Plugin */~' | perl -pe 'chomp if eof' > dist/howler.min.js && awk '(NR>1 && FNR==1){printf (\"\\n\\n\")};1' src/howler.core.js src/plugins/howler.spatial.js > dist/howler.js",
Expand All @@ -37,5 +37,8 @@
"dist/howler.core.min.js",
"dist/howler.spatial.min.js",
"LICENSE.md"
]
}
],
"publishConfig": {
"registry": "https://npm.pkg.github.com"
}
}
Loading