Created
December 2, 2013 22:59
-
-
Save philipbreau/7760631 to your computer and use it in GitHub Desktop.
Microphone Tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/> | |
<script type="text/javascript" src="http://bridgeit.github.io/bridgeit.js/src/bridgeit.js"></script> | |
</head> | |
<body> | |
<style> | |
.button{ | |
height: 80px; | |
margin: 10px 0; | |
padding: 10px; | |
width: 100%; | |
border: 1px solid #333; | |
background: linear-gradient(to bottom, #EEE 0%, #DDD 100%); | |
text-decoration: none; | |
color: #333; | |
font-size: 16px; | |
line-height: 60px; | |
font-weight: bold; | |
display: block; | |
box-sizing: border-box; | |
} | |
</style> | |
<script type="text/javascript"> | |
var uploadServiceURL = 'http://api.bridgeit.mobi/echo/'; | |
function onAfterAudioCapture(event){ | |
if (event.response) { | |
var btn = document.getElementById('micBtn'); | |
var audioSrc = event.response; | |
var audioElem = document.createElement('audio'); | |
audioElem.setAttribute('src', audioSrc); | |
audioElem.setAttribute('controls', 'controls'); | |
audioElem.setAttribute('preload', 'auto'); | |
audioElem.setAttribute('type', 'audio/mp3'); | |
micBtn.parentNode.appendChild(audioElem); | |
} | |
} | |
</script> | |
<button id='micBtn' class="button" type="button" | |
onclick="bridgeit.microphone('micBtn', 'onAfterAudioCapture', {postURL: uploadServiceURL + 'audio-upload/'});"> | |
Record Audio</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment