A Pen by kiko vidal on CodePen.
Created
September 27, 2021 08:09
-
-
Save OhmDios/4c4f011908551b76c505420221599fe0 to your computer and use it in GitHub Desktop.
Music and radio player/Reproductor de musica y radio
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
<div id="reproductor"> | |
<audio src="" id="audio"></audio> | |
<div class="conte-disk"> | |
<div id="cd"> | |
<img src="https://www.nierle.com/pic/5884b.jpg" alt="img-cd" class="cd"> | |
</div> | |
<div id="central"></div> | |
</div> | |
<div class="conte-controll"> | |
<div id="lcd"> | |
<div class="lcd-song"> | |
<div id="song-title"></div> | |
</div> | |
<div class="lcd-time"> | |
<div id="song-time"></div> | |
</div> | |
</div> | |
<div class="btn-controll"> | |
<button class="boton-control" id="rebackward"> | |
<i class="fa fa-fast-backward"></i></button> | |
<button class="boton-control" id="backward"> | |
<i class="fa fa-backward"></i></button> | |
<button class="boton-control" id="play"> | |
<i class="fa fa-play"></i></button> | |
<button class="boton-control" id="pause"> | |
<i class="fa fa-pause"></i></button> | |
<button class="boton-control" id="stop"> | |
<i class="fa fa-stop"></i></button> | |
<button class="boton-control" id="forward"> | |
<i class="fa fa-forward"></i></button> | |
<button class="boton-control" id="reforward"> | |
<i class="fa fa-fast-forward"></i></button> | |
</div> | |
</div> | |
<div class="conte-radio"> | |
<button class="boton-radio" id="radio"> | |
<i class="radio">Radio</i></button> | |
<button class="boton-radio" id="rest-emi"> | |
<i class="fa fa-step-backward"></i></button> | |
<button class="boton-radio" id="plus-emi"> | |
<i class="fa fa-step-forward"></i></button> | |
</div> | |
<div class="conte-list"> | |
<button class="fa fa-music" id="list"></button> | |
<p>0</p> | |
<input type="range" id="volume" value="80" step="1"> | |
<p>100</p> | |
<div id="list-list"> | |
<div id="text-list"></div> | |
<span class="arrow"></span> | |
</div> | |
</div> | |
</div> |
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
$(function () { | |
var songList = [ | |
'https://newtabz.stream/stream/kuWBZB:qF12rB', | |
'https://newtabz.stream/stream/WsTtuH:zvkAfB', | |
'https://newtabz.stream/stream/quWBZB:X2u1rB', | |
'https://newtabz.stream/stream/vuWBZB:Dpx1rB' | |
]; | |
var songTitle = [ | |
'Marisol - Tombola', | |
'Stryper - Calling on you', | |
'La fuga - Por verte sonreir', | |
'Manolo Escobar - yo soy un hombre de campo' | |
]; | |
var foto = [ | |
'https://cloud10.todocoleccion.online/musica-cds/tc/2012/09/11/33204991.jpg', | |
'https://www.spirit-of-metal.com/les%20goupes/S/Stryper/pics/1193645_logo.jpg', | |
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSOrVQ2xvsRfHGiEk7rQrij6jMx5EJAjCCqAuJhmXi63tJSQmcu', | |
'https://sgfm.elcorteingles.es/SGFM/dctm/MEDIA01/201311/07/00105119129533____1__600x600.jpg' | |
]; | |
var emisor = [ | |
'http://195.10.10.201/cope/rockfm.mp3', | |
'http://kissfm.kissfmradio.cires21.com/kissfm.mp3', | |
'http://radiomarca.streaming-pro.com:8030/radiomarca.mp3', | |
'http://195.10.10.206/rtve/rtve-rne.mp3' | |
]; | |
var emisorName = [ | |
'Rock FM', | |
'Kiss FM', | |
'Radio Marca', | |
'Rtve rtve-rne' | |
]; | |
var song = songList.length, | |
band = emisor.length, | |
posSong = 0, | |
posSongtitle = 0, | |
posFoto = 0, | |
posEmisor = 0, | |
posEmisorName = 0, | |
audio = document.getElementById('audio'), | |
min = Math.floor(audio.currentTime / 60), | |
seg = Math.floor(audio.currentTime % 60); | |
audio.src = songList[posSong]; | |
$('#rebackward').on('click', rebackward); | |
$('#backward').on('click', backward); | |
$('#play').on('click', repro); | |
$('#pause').on('click', pausa); | |
$('#stop').on('click', stop); | |
$('#forward').on('click', forward); | |
$('#reforward').on('click', reforward); | |
$('#list').on('click', lista); | |
$('#radio').on('click', radiola); | |
$('#rest-emi').on('click', restEmi); | |
$('#plus-emi').on('click', plusEmi); | |
var volumeslider = document.getElementById('volume') | |
volumeslider.addEventListener("change",setvolume,false); | |
function rebackward() { | |
posSong--; | |
posSongtitle--; | |
posFoto--; | |
audio.src = songList[posSong]; | |
$('.cd').attr('src', foto[posFoto]); | |
audio.play(); | |
look(); | |
if(posSong <= 0) { | |
posSong = song; | |
} | |
if(posSong <= 0) { | |
posSongtitle = song; | |
} | |
if(posSong <= 0) { | |
posFoto = song; | |
} | |
} | |
function backward() { | |
audio.currentTime -= 10; | |
audio.play(); | |
} | |
function repro() { | |
$('.boton-radio').prop('disabled', true); | |
$('.boton-radio').css('color', '#ccc'); | |
$('#play').css('display', 'none'); | |
$('#pause').css('display', 'block'); | |
audio.play(); | |
$('.cd').attr('src', foto[posFoto]); | |
$('#cd').addClass('spin'); | |
look(); | |
} | |
function pausa() { | |
audio.pause(); | |
$(this).css('display', 'none'); | |
$('#play').css('display', 'block'); | |
$('#cd').removeClass('spin'); | |
} | |
function stop() { | |
audio.pause(); | |
$('#pause').css('display', 'none'); | |
$('#play').css('display', 'block'); | |
$('#cd').removeClass('spin'); | |
audio.src = songList[posSong]; | |
$('#song-title').html(''); | |
$('.boton-radio').prop('disabled', false); | |
$('.boton-radio').css('color', 'aqua'); | |
$('.cd').attr('src', 'https://www.nierle.com/pic/5884b.jpg'); | |
$('#song-time').css('color', '#000'); | |
} | |
function forward() { | |
audio.currentTime += 10; | |
audio.play(); | |
} | |
function reforward() { | |
posSong++; | |
posSongtitle++; | |
posFoto++; | |
audio.src = songList[posSong]; | |
$('.cd').attr('src', foto[posFoto]); | |
audio.play(); | |
look(); | |
if(posSong >= song - 1) { | |
posSong = -1; | |
} | |
if(posSongtitle >= song - 1) { | |
posSongtitle = -1; | |
} | |
if(posFoto >= song - 1) { | |
posFoto = -1; | |
} | |
} | |
var rad = false; | |
// RADIO | |
function radiola() { | |
if (!rad) { | |
$(this).css('color', 'pink'); | |
$('.boton-control').prop('disabled', true); | |
$('.boton-control').css('color', '#ccc'); | |
audio.src = emisor[posEmisor]; | |
audio.play(); | |
look2(); | |
rad = true; | |
} else { | |
$(this).css('color', 'aqua'); | |
$('.boton-control').prop('disabled', false); | |
$('.boton-control').css('color', 'aqua'); | |
audio.src = songList[posSong]; | |
audio.pause(); | |
$('#song-title').html(''); | |
rad = false; | |
} | |
} | |
function restEmi() { | |
posEmisor--; | |
posEmisorName--; | |
audio.src = emisor[posEmisor]; | |
audio.play(); | |
look2(); | |
if(posEmisor <= 0) { | |
posEmisor = band; | |
posEmisorName = band; | |
} | |
} | |
function plusEmi() { | |
posEmisor++; | |
posEmisorName++; | |
audio.src = emisor[posEmisor]; | |
audio.play(); | |
look2(); | |
if(posEmisor >= band - 1) | |
posEmisor = -1; | |
if(posEmisorName >= band - 1) | |
posEmisorName = -1; | |
} | |
function lista() { | |
$('#list-list').toggleClass('open'); | |
} | |
function setvolume() { | |
audio.volume = volumeslider.value / 100; | |
} | |
var texto = document.getElementById('text-list'); | |
for(var i=0; i <=song - 1; i++) { | |
texto.innerHTML = texto.innerHTML + '<div class="temuca">'+songTitle[i] +'</div>'; | |
} | |
function pass() { | |
if(audio.duration == audio.currentTime) | |
reforward(); | |
} | |
setInterval(pass, 1000); | |
function look() { | |
$('#song-title').html("♫♪♫ " + (posSong + 1) + ": " + songTitle[posSongtitle] + " ♫♪♫ "); | |
$('#song-time').css('color', 'aqua'); | |
var getTimeString = function (timeInMs) { | |
var point = ":", | |
minutes = Math.floor((timeInMs / (1000 * 60)) % 60), | |
seconds = Math.floor((timeInMs / 1000) % 60); | |
if (minutes < 10) { | |
minutes = "0" + minutes | |
} | |
if (seconds < 10) { | |
seconds = "0" + seconds; | |
} | |
return minutes + point + seconds; | |
} | |
audio.ontimeupdate = function () { | |
$('#song-time').html(getTimeString(audio.currentTime * 1000) + '<br>' + getTimeString(audio.duration * 1000)); | |
}; | |
} | |
function look2() { | |
$('#song-title').html('<span><i class="fa fa-microphone">' + " " + '</i></span>' + " " + (posEmisor + 1) + ": " + emisorName[posEmisorName] + " " + '<span><i class="fa fa-microphone">' + " " + '</i></span>'); | |
} | |
}); |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
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
*{ | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body{ | |
font-family: 'Chakra Petch', sans-serif; | |
} | |
#reproductor { | |
position: relative; | |
width: 420px; | |
height: auto; | |
background-color: #444; | |
border: solid #333; | |
border-radius: 50px 0 0 0; | |
margin: 100px auto; | |
display: flex; | |
flex-wrap: wrap; | |
justify-content: space-between; | |
align-items: center; | |
padding: 10px; | |
} | |
/************************************************ | |
*************** DISK **************************** | |
************************************************/ | |
.conte-disk { | |
position: relative; | |
width: 100px; | |
height: 100px; | |
padding: 3px; | |
border: solid #fff; | |
border-radius: 100%; | |
} | |
#cd { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
border-radius: 100%; | |
overflow: hidden; | |
} | |
.cd { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
} | |
#central { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translateX(-50%) translateY(-50%); | |
width: 20px; | |
height: 20px; | |
background-color: #000; | |
border: 2px solid #fff; | |
border-radius: 100%; | |
display: none; | |
} | |
#cd.spin { | |
animation: roller 3s linear infinite; | |
} | |
#cd.spin ~ #central { | |
display: block; | |
} | |
@keyframes roller { | |
0%{transform: rotateZ(0);} | |
100%{transform: rotateZ(360deg);} | |
} | |
/************************************************ | |
*************** SCREEN ************************* | |
************************************************/ | |
#lcd { | |
position: relative; | |
width: 220px; | |
height: 30px; | |
color: aqua; | |
display: flex; | |
justify-content: space-between; | |
align-items: center; | |
background-color: #000; | |
} | |
.lcd-song { | |
width: 80%; | |
font-size: 14px; | |
overflow: hidden; | |
} | |
#song-title { | |
width: 400px; | |
height: auto; | |
animation: pass 10s linear infinite; | |
} | |
@keyframes pass { | |
0%{margin-left: 220px;} | |
40%{margin-left: 0px;} | |
60%{margin-left: 0px;} | |
100%{margin-left: -400px;} | |
} | |
.lcd-time { | |
position: relative; | |
width: 19%; | |
height: 100%; | |
text-align: center; | |
} | |
#song-time{ | |
font-size: 11px; | |
color: aqua; | |
} | |
/************************************************ | |
*************** BOTONES ************************* | |
************************************************/ | |
.conte-radio { | |
position: relative; | |
width: 65px; | |
height: 100px; | |
border-top: 1px solid #999; | |
border-left: 1px solid #999; | |
border-right: solid #333; | |
border-bottom: solid #333; | |
display: flex; | |
flex-wrap: wrap; | |
justify-content: space-around; | |
padding: 20px 3px 0 3px; | |
} | |
#radio { | |
width: 50px; | |
height: 25px; | |
} | |
#rest-emi, #plus-emi { | |
width: 25px; | |
height: 25px; | |
} | |
.btn-controll { | |
width: 100%; | |
height: auto; | |
display: flex; | |
justify-content: space-around; | |
margin-top: 20px; | |
border-top: 1px solid #999; | |
border-left: 1px solid #999; | |
border-right: solid #333; | |
border-bottom: solid #333; | |
padding: 10px 0; | |
} | |
.boton-control { | |
width: 25px; | |
height: 25px; | |
} | |
button { | |
background: linear-gradient(#777, #aaa); | |
color: aqua; | |
border: none; | |
} | |
button:hover { | |
background: linear-gradient(#aaa, #777); | |
} | |
#pause { | |
display: none; | |
} | |
.conte-list { | |
position: relative; | |
width: 80%; | |
height: 25px; | |
margin: 10px auto 0; | |
display: flex; | |
justify-content: flex-end; | |
} | |
#list { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 25px; | |
height: 25px; | |
} | |
#volume { | |
width: 200px; | |
margin-left: 5px; | |
margin-right: 5px; | |
cursor: pointer; | |
} | |
input[type=range] { | |
-webkit-appearance: none; | |
width: 100%; | |
margin: 13.2px 0; | |
} | |
input[type=range]:focus { | |
outline: none; | |
} | |
input[type=range]::-webkit-slider-runnable-track { | |
width: 100%; | |
height: 12.6px; | |
cursor: pointer; | |
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; | |
background: #928483; | |
border-radius: 6.2px; | |
border: 0.7px solid #562425; | |
} | |
input[type=range]::-webkit-slider-thumb { | |
box-shadow: 1px 1px 1px #050000, 0px 0px 1px #1f0000; | |
border: 2.2px solid #000000; | |
height: 39px; | |
width: 19px; | |
border-radius: 2px; | |
background: #6ed8e8; | |
cursor: pointer; | |
-webkit-appearance: none; | |
margin-top: -13.9px; | |
} | |
input[type=range]:focus::-webkit-slider-runnable-track { | |
background: #9e9191; | |
} | |
input[type=range]::-moz-range-track { | |
width: 100%; | |
height: 12.6px; | |
cursor: pointer; | |
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; | |
background: #928483; | |
border-radius: 6.2px; | |
border: 0.7px solid #562425; | |
} | |
input[type=range]::-moz-range-thumb { | |
box-shadow: 1px 1px 1px #050000, 0px 0px 1px #1f0000; | |
border: 2.2px solid #000000; | |
height: 39px; | |
width: 19px; | |
border-radius: 2px; | |
background: #6ed8e8; | |
cursor: pointer; | |
} | |
input[type=range]::-ms-track { | |
width: 100%; | |
height: 12.6px; | |
cursor: pointer; | |
background: transparent; | |
border-color: transparent; | |
color: transparent; | |
} | |
input[type=range]::-ms-fill-lower { | |
background: #867776; | |
border: 0.7px solid #562425; | |
border-radius: 12.4px; | |
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; | |
} | |
input[type=range]::-ms-fill-upper { | |
background: #928483; | |
border: 0.7px solid #562425; | |
border-radius: 12.4px; | |
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; | |
} | |
input[type=range]::-ms-thumb { | |
box-shadow: 1px 1px 1px #050000, 0px 0px 1px #1f0000; | |
border: 2.2px solid #000000; | |
height: 39px; | |
width: 19px; | |
border-radius: 2px; | |
background: #6ed8e8; | |
cursor: pointer; | |
height: 12.6px; | |
} | |
input[type=range]:focus::-ms-fill-lower { | |
background: #928483; | |
} | |
input[type=range]:focus::-ms-fill-upper { | |
background: #9e9191; | |
} | |
.conte-list p { | |
color:aqua; | |
} | |
#list-list { | |
position: absolute; | |
top: 25px; | |
left: 50px; | |
width:0px; | |
height: 0px; | |
background-color: #666; | |
padding: 10px; | |
border-radius: 0 15px 15px 15px; | |
opacity: 0; | |
transition: 1s all ease-in-out; | |
} | |
#text-list { | |
position: relative; | |
width: 100%; | |
height: 100%; | |
background-color: #000; | |
border-radius: 15px; | |
font-size: 12px; | |
color: yellow; | |
overflow: hidden; | |
padding: 10px; | |
} | |
.arrow{ | |
position: absolute; | |
top: -10px; | |
left: -25px; | |
width: 0; | |
height: 0; | |
border-left: 40px solid #666; | |
border-top: 10px solid transparent; | |
border-bottom: 10px solid transparent; | |
transform: rotateZ(-150deg); | |
z-index: 5; | |
} | |
#list-list.open { | |
width: 300px; | |
height: auto; | |
opacity: 1; | |
} | |
.temuca { | |
cursor: pointer; | |
} | |
.temuca:hover { | |
color: red; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment