Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed iOS issues with WebAudio "extra" plugin.

Signed-off-by: Lanny McNie <lanny@gskinner.com>
  • Loading branch information...
commit 92cb9b8d5b2344577c96898df2e40a1682a328aa 1 parent 9384869
@lannymcnie lannymcnie authored
Showing with 11 additions and 10 deletions.
  1. +11 −10 extras/WebAudioPlugin.js
View
21 extras/WebAudioPlugin.js
@@ -59,16 +59,17 @@
if (s.capabilities != null) { return; }
var audio = null;
+ if (window.Audio) { // iOS changed how they define this, so it is no longer returns as a typeof == "function"
+ audio = document.createElement("audio");
+ } else {
+ return;
+ }
- if (typeof Audio == "function") {
- audio = new Audio(); // could use instead -> document.createElement("audio");
- }
-
- if(typeof AudioContext == "function") {
+ if(window.AudioContext) {
s.context = new AudioContext();
- } else if (typeof webkitAudioContext == "function") {
- s.context = new webkitAudioContext();
- }
+ } else if (window.webkitAudioContext) {
+ s.context = new webkitAudioContext();
+ }
if (audio && s.context) {
s.capabilities = {
@@ -173,9 +174,9 @@
this.lastPlaybackCurrentTime = WebAudioPlugin.context.currentTime;
- setTimeout(createjs.SoundJS.proxy(this.handlePlaybackComplete, this), source.buffer.duration*1000);
+ setTimeout(createjs.SoundJS.proxy(this.handlePlaybackComplete, this), source.buffer.duration*1000); // NOTE *1000 because WebAudio reports everything in seconds but js uses milliseconds
- //LM: Should we do this?
+ //LM: Should we do this? //OJR Yes, it is the only way to keep the sound playing smoothly. But it might need to be set before the buffer is set.
if (loop === true) {
source.loop = true;
}

2 comments on commit 92cb9b8

@fatlinesofcode

Anyone else find this latest version commit crashes Chrome?

@lannymcnie
Collaborator

Please check out the version in the Version_040 branch, which is a fully functional WebAudio plugin. It should be merged in the next few days.

Please sign in to comment.
Something went wrong with that request. Please try again.