Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for working with arbitrary audio element
- Loading branch information
Showing
16 changed files
with
521 additions
and
51 deletions.
There are no files selected for viewing
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
@font-face { | ||
font-family: 'League Gothic'; | ||
src: url('League_Gothic-webfont.eot'); | ||
src: url('League_Gothic-webfont.eot?') format('embedded-opentype'), | ||
url('League_Gothic-webfont.woff') format('woff'), | ||
url('League_Gothic-webfont.ttf') format('opentype'); | ||
font-weight: bold; | ||
font-style: normal; | ||
} | ||
body { | ||
background-color: #000; | ||
margin: 0; | ||
padding: 0; | ||
font-family: Arial; | ||
} | ||
#info { | ||
width: 100%; | ||
position: absolute; | ||
top: 0; | ||
height: 52px; | ||
background-color: #111; | ||
color: #ccc; | ||
font-family: 'League Gothic', arial, sans-serif; | ||
} | ||
#info h1 { | ||
margin: 0 0 0 20px; | ||
float: left; | ||
font-size: 40px; | ||
color: #ff0077; | ||
} | ||
#info h2 { | ||
margin: 14px 0 0 5px; | ||
float: left; | ||
font-size: 25px; | ||
} | ||
|
||
#info h3 { | ||
margin: 19px 0 0 15px; | ||
float: left; | ||
font-size: 20px; | ||
} | ||
|
||
#info ul { | ||
float:right; | ||
display-icon-type:none; | ||
} | ||
|
||
#info li { | ||
display:block; | ||
float:left; | ||
margin-right: 15px; | ||
} | ||
|
||
#info li a { | ||
color: #ff0077; | ||
margin-left: 5px; | ||
} | ||
|
||
#loading { | ||
font-size: 60px; | ||
color: #fff; | ||
width: 500px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
margin-top: 100px; | ||
background-color: #111; | ||
padding: 10px; | ||
-webkit-border-radius: 10px; | ||
-moz-border-radius: 10px; | ||
border-radius: 10px; | ||
opacity: 0.9; | ||
border: 1px solid #ccc; | ||
text-align: center; | ||
} | ||
|
||
#loading a { | ||
color: #fff; | ||
text-shadow: 0 0 10px #fff; | ||
text-decoration: none; | ||
} | ||
|
||
#loading p{ | ||
color: #fff; | ||
font-size: 18px; | ||
} | ||
|
||
#waveform { | ||
display: block; | ||
margin: 100px auto; | ||
} | ||
|
||
#stats { | ||
margin: 0 0 0 10px; | ||
float: left; | ||
} | ||
|
||
#songinfo { | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
background-color: #111; | ||
} | ||
|
||
#songinfo span, #songinfo h3 { | ||
color: #ccc; | ||
font-size: 12px; | ||
margin: 5px 30px 5px 30px; | ||
padding: 0; | ||
} | ||
|
||
#songinfo a { | ||
color: #ff0077; | ||
} | ||
|
||
audio { | ||
width: 400px; | ||
display: block; | ||
margin: 100px auto; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link href='http://fonts.googleapis.com/css?family=Duru+Sans' rel='stylesheet' type='text/css'> | ||
<link href='css/dancer.css' rel='stylesheet' type='text/css'> | ||
</head> | ||
<body> | ||
<div id="info"> | ||
<h1>dancer.js</h1> | ||
<h2>JavaScript Audio Library</h2> | ||
<h3>Simple Waveform</h3> | ||
<ul> | ||
<li><a href="https://github.com/jsantell/dancer.js" title="dancer.js on github">view API/source</a></li> | ||
<li>by <a href="http://jsantell.com" title="Jordan Santell">jordan santell</a></li> | ||
</ul> | ||
</div> | ||
<audio id="audio" controls="controls"> | ||
<source src="../songs/Fire Hive (Krewella fuck on me remix).ogg" type="audio/ogg" /> | ||
<source src="../songs/Fire Hive (Krewella fuck on me remix).mp3" type="audio/mpeg" /> | ||
</audio> | ||
<div id="loading">Loading . . .</div> | ||
<canvas id="waveform" height="600" width="1024"></canvas> | ||
<div id="songinfo"> | ||
<span>Now playing...</span> | ||
<h3><a href="http://zirconstudios.bandcamp.com/album/unearthed" title="Zircon Studios Bandcamp">Zircon - Devil's Spirit</a></h3> | ||
</div> | ||
<!-- Dancer.js --> | ||
<script src="../../src/dancer.js"></script> | ||
<script src="../../src/support.js"></script> | ||
<script src="../../src/beat.js"></script> | ||
<script src="../../src/adapterWebkit.js"></script> | ||
<script src="../../src/adapterMoz.js"></script> | ||
<script src="../../src/adapterFlash.js"></script> | ||
<script src="../../lib/fft.js"></script> | ||
<script src="../../lib/flash_detect.js"></script> | ||
<script src="../../plugins/dancer.fft.js"></script> | ||
<script src="../../plugins/dancer.waveform.js"></script> | ||
|
||
<!-- Demo stuff --> | ||
<script src="js/player.js"></script> | ||
</body> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
(function () { | ||
|
||
var | ||
audio = document.getElementById( 'audio' ), | ||
waveform = document.getElementById( 'waveform' ), | ||
ctx = waveform.getContext( '2d' ), | ||
dancer, beat; | ||
|
||
/* | ||
* Dancer.js magic | ||
*/ | ||
Dancer.setOptions({ | ||
flashSWF : '../../lib/soundmanager2.swf', | ||
flashJS : '../../lib/soundmanager2.js' | ||
}); | ||
|
||
dancer = new Dancer(); | ||
beat = dancer.createBeat({ | ||
onBeat: function () { | ||
ctx.strokeStyle = '#ff0077'; | ||
}, | ||
offBeat: function () { | ||
ctx.strokeStyle = '#666'; | ||
} | ||
}).on(); | ||
|
||
dancer | ||
.load( audio ) | ||
.waveform( waveform, { strokeStyle: '#666', strokeWidth: 2 }); | ||
|
||
Dancer.isSupported() || loaded(); | ||
!dancer.isLoaded() ? dancer.bind( 'loaded', loaded ) : loaded(); | ||
|
||
/* | ||
* Loading | ||
*/ | ||
|
||
function loaded () { | ||
var | ||
loading = document.getElementById( 'loading' ), | ||
anchor = document.createElement('A'), | ||
supported = Dancer.isSupported(), | ||
p; | ||
|
||
anchor.appendChild( document.createTextNode( supported ? 'Play!' : 'Close' ) ); | ||
anchor.setAttribute( 'href', '#' ); | ||
loading.innerHTML = ''; | ||
loading.appendChild( anchor ); | ||
|
||
if ( !supported ) { | ||
p = document.createElement('P'); | ||
p.appendChild( document.createTextNode( 'Your browser does not currently support either Web Audio API or Audio Data API. The audio may play, but the visualizers will not move to the music; check out the latest Chrome or Firefox browsers!' ) ); | ||
loading.appendChild( p ); | ||
} | ||
|
||
anchor.addEventListener( 'click', function () { | ||
dancer.play(); | ||
document.getElementById('loading').style.display = 'none'; | ||
}); | ||
} | ||
|
||
// For debugging | ||
window.dancer = dancer; | ||
|
||
})(); |
This file contains 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
This file contains 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
Oops, something went wrong.