Skip to content

Instantly share code, notes, and snippets.

View danpastori's full-sized avatar
✍️
Writing a book about building APIs and SPAs with @vuejs & @laravel

Dan Pastori danpastori

✍️
Writing a book about building APIs and SPAs with @vuejs & @laravel
View GitHub Profile
@danpastori
danpastori / basic_html5_audio_tag.html
Created March 7, 2014 20:29
[761][1] Basic HTML 5 Audio Tag
<audio id="song" width="300" height="32" ontimeupdate="updateTime()"><source src="path/to/music.mp3" type="audio/mp3" /></audio>
@danpastori
danpastori / default_html5_audio_tag.html
Created March 7, 2014 20:41
[761][2] Default HTML5 Audio Tag
<audio id="song" width="300" height="32" ontimeupdate="updateTime()" controls="controls"><source src="path/to/music.mp3" type="audio/mp3" /></audio>
@danpastori
danpastori / css_play_description.css
Created March 7, 2014 20:49
[761][4] CSS Play Button
#songPlay{
}
@danpastori
danpastori / pause_css.css
Created March 7, 2014 20:52
[761][5] Pause Button Implementation
#songPause{
}
@danpastori
danpastori / play_pause.js
Created March 7, 2014 20:54
[761][6] Play Pause Button
//Does a switch of the play/pause with one button.
function playPause(id){
//Sets the active song since one of the functions could be play.
activeSong = document.getElementById(id);
//Checks to see if the song is paused, if it is, play it from where it left off otherwise pause it.
if (activeSong.paused){
activeSong.play();
}else{
@danpastori
danpastori / play_pause_css.css
Created March 7, 2014 20:57
[761][7] Play Pause HTML and CSS
#songPlayPause{
}
@danpastori
danpastori / stop_button.js
Created March 7, 2014 20:59
[761][8] Stop Button
//Stop song by setting the current time to 0 and pausing the song.
function stopSong(){
activeSong.currentTime = 0;
activeSong.pause();
}
@danpastori
danpastori / volume.js
Created March 7, 2014 21:01
[761][9] Volume Management Javascript
//Changes the volume up or down a specific number
function changeVolume(number, direction){
//Checks to see if the volume is at zero, if so it doesn't go any further.
if(activeSong.volume &gt;= 0 &amp;&amp; direction == "down"){
activeSong.volume = activeSong.volume - (number / 100);
}
//Checks to see if the volume is at one, if so it doesn't go any higher.
if(activeSong.volume activeSong.volume = activeSong.volume + (number / 100);
}
@danpastori
danpastori / volume.css
Created March 7, 2014 21:03
[761][10] Volume Up and Down CSS and HTML
/*Volume Up Button*/
#volumeUp{
}
/*Volume Down Button*/
#volumeDown{
}
@danpastori
danpastori / volume_percentage.js
Created March 7, 2014 21:04
[761][11] Volume Percentage Javascript
//Set's volume as a percentage of total volume based off of user click.
function setVolume(percentage){
activeSong.volume = percentage;
var percentageOfVolume = activeSong.volume / 1;
var percentageOfVolumeSlider = document.getElementById('volumeMeter').offsetWidth * percentageOfVolume;
document.getElementById('volumeStatus').style.width = Math.round(percentageOfVolumeSlider) + "px";
}