Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 3 commits into from

4 participants

@jsantell

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 Collaborator

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

excessive parens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@paulirish
Owner

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

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

@jsantell

Got a little too excited, should be good now!

@patrickkettner patrickkettner referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@patrickkettner patrickkettner referenced this pull request from a commit in patrickkettner/Modernizr
@patrickkettner patrickkettner 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.
53424e1
@stucox
Owner

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
@patrickkettner patrickkettner referenced this pull request from a commit in patrickkettner/Modernizr
@patrickkettner patrickkettner 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.
205b49a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. @jsantell
Commits on Oct 7, 2012
  1. @jsantell

    Remove excessive parens

    jsantell authored
Commits on Oct 12, 2012
  1. @jsantell
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  feature-detects/audio-audiodata-api.js
View
2  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', !!(window.Audio && (new window.Audio()).mozSetup));
Something went wrong with that request. Please try again.