Fix Audio Data API test to detect API, not Audio element #721

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants

jsantell commented Oct 4, 2012

As it was, !!(window.Audio) in the Audio Data API test will return true for any browser that supports Audio elements (Chrome, Safari, Firefox..), not the Mozilla Audio Data API. As per the spec, Audio objects in Firefox 4+ support the mozSetup method, and pass in FF4+, and fail (appropriately) in other browsers.

feature-detects/audio-audiodata-api.js
@@ -1,4 +1,4 @@
// Mozilla Audio Data API
// https://wiki.mozilla.org/Audio_Data_API
// by Addy Osmani
-Modernizr.addTest('audiodata', !!(window.Audio));
+Modernizr.addTest('audiodata', !!((new window.Audio()).mozSetup));
@sindresorhus

sindresorhus Oct 7, 2012

Member

Modernizr.addTest('audiodata', !!(new window.Audio()).mozSetup);

excessive parens

Owner

paulirish commented Oct 10, 2012

this test assumes a window.Audio global to be present.

can you test this in browsers before adding the next commits?

Got a little too excited, should be good now!

patrickkettner added a commit to patrickkettner/Modernizr that referenced this pull request Aug 19, 2013

Remove audio data test
Originally noted in #721, the current test only checks for audio
elements on the window. This results in true in pretty much all
browsers. Audio data only exists in FF as a depricated API. The test is
currently broken. I created a new pull since the old one (#721) was old
and out of date.
Owner

stucox commented Aug 19, 2013

Thanks for this, but we've decided to drop this detect as the API has been superseded by the Web Audio API – see #1019.

Shout if you think that's the wrong decision!

@stucox stucox closed this Aug 19, 2013

patrickkettner added a commit to patrickkettner/Modernizr that referenced this pull request Feb 22, 2015

Remove audio data test
Originally noted in #721, the current test only checks for audio
elements on the window. This results in true in pretty much all
browsers. Audio data only exists in FF as a depricated API. The test is
currently broken. I created a new pull since the old one (#721) was old
and out of date.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment