Skip to content

Instantly share code, notes, and snippets.

@rmedinap
Created June 1, 2017 06:18
Show Gist options
  • Save rmedinap/62dc5bb77007f3820873744ea5bc7a4a to your computer and use it in GitHub Desktop.
Save rmedinap/62dc5bb77007f3820873744ea5bc7a4a to your computer and use it in GitHub Desktop.
Audio 3
<body>
<div id="reproductor" >
<button class="power" title="Power" ></button>
<button class="play" title="Play" ></button>
<button class="stop" title="Stop"></button>
<button class="pause" title="Pausa" ></button>
</div>
<div><audio id="miaudio" src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-16.mp3" controls="controls"></audio>
</div>
</body>
$(document).ready(function(){
$(".power").click(function(){
$("#miaudio")[0].pause();
$("#miaudio")[0].currentTime=0;
$("#miaudio").toggle();
})
$(".play").click(function(){
$("#miaudio")[0].play();
})
$(".stop").click(function(){
$("#miaudio")[0].pause();
$("#miaudio")[0].currentTime=0;
})
$(".pause").click(function(){
$("#miaudio")[0].pause();
})
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
#reproductor{
border: 1px solid black;
padding: 10px;
text-align: justify;
font-size: 0.1px; /* IE 9/10 don't like font-size: 0; */
width: 300px;
}
#miaudio{
margin-top:20px;
display:none;
}
button {
width: 56px;
height: 56px;
border: none;
border-radius: 28px;
box-shadow: 3px 3px 8px black;
display: inline-block;
opacity: 0.6;
}
#reproductor:after {
content: '';
width: 100%; /* Ensures there are at least 2 lines of text, so justification works */
display: inline-block;
}
button.power {
background: url("http://uploads.webflow.com/5919bfe92a8ec84e2e204170/592d8adc1d607d1d72b03e71_buttons-for-music-player-p-500.jpeg") -2px -1px;
}
button.power:hover {
opacity: 1;
}
button.play {
background: url("http://uploads.webflow.com/5919bfe92a8ec84e2e204170/592d8adc1d607d1d72b03e71_buttons-for-music-player-p-500.jpeg") -89px -1px;
}
button.play:hover {
opacity: 1;
}
button.stop {
background: url("http://uploads.webflow.com/5919bfe92a8ec84e2e204170/592d8adc1d607d1d72b03e71_buttons-for-music-player-p-500.jpeg") -177px -1px;
}
button.stop:hover {
opacity: 1;
}
button.pause {
background: url("http://uploads.webflow.com/5919bfe92a8ec84e2e204170/592d8adc1d607d1d72b03e71_buttons-for-music-player-p-500.jpeg") -264px -1px;
}
button.pause:hover {
opacity: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment