Skip to content

Instantly share code, notes, and snippets.

@jedfoster
Last active August 29, 2015 14:03
Show Gist options
  • Save jedfoster/cb6ddc45da6347873010 to your computer and use it in GitHub Desktop.
Save jedfoster/cb6ddc45da6347873010 to your computer and use it in GitHub Desktop.
How to programmatically call "play()" on an AudioJS element

In reply to @bimbe_lien on Twitter.

AudioJS elements expose a player object, with a play() method that can be called programmatically—from outside of the element.

Try this:

  1. Open http://jedfoster.com/AudioJS/ in your browser
  2. Open the console and paste in this: document.body.querySelector(".tube-css audio").player.play();

Note that the AudioJS element is the <audio> tag.

So you to wire up an outside element you could do:

$('#outsideElement').click(function() { $('#audioPlayer').player.play(); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment