audia icon indicating copy to clipboard operation
audia copied to clipboard

TypeError: 'undefined' is not a function

Open jon-moreira opened this issue 13 years ago • 1 comments

I have this error undefined is not a function when using Audia in iPad and iPhone.

Works good in chrome and others browsers...

[code] this.playCorrectSound = function (){ var correctSound = new Audia(); correctSound.volume = 30; correctSound.src = "assets/Uploads/audio/correct.mp3"; correctSound.play(); } [/code]

if print correctSound before call play, have this

Object _currentTime: 0 _duration: 0 _gain: null _id: 1 _muted: false _onendedTimeout: null _playing: false _source: null _startTime: null _volume: 1 src: "assets/Uploads/audio/correct.mp3" volume: 30 proto: —

jon-moreira avatar Jan 05 '13 17:01 jon-moreira

In Safari (on OSX at least) this bit is faulty: // Got Web Audio API? var audioContext = null; if (typeof AudioContext == "function") { audioContext = new AudioContext(); } else if (typeof webkitAudioContext == "function") { audioContext = new webkitAudioContext(); }

typeof returns "object" for both AudioContext and webkitAudioContext, so I propose a change something along the lines of this:

// Got Web Audio API? var audioContext = null; if (typeof AudioContext != "undefined") { audioContext = new AudioContext(); } else if (typeof webkitAudioContext != "undefined") { audioContext = new webkitAudioContext(); }

I am unsure if this helps on iPhone/iPad but it certainly helps on OSX.

bstrr avatar Sep 05 '15 19:09 bstrr