음악 재생기 사용자 정의

15695 단어
DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>title>
    head>
    <body>
        
<div> 
 <h4 id="name">h4>
 <br>
<audio id="audio" src="  -   (DJ ).mp3 " controls autoplay="true">audio><br/>
div>
<br><br>
<div>
<button id="btn-play" > button>  
<button id="btn-stop" > button>  
<button id="btn-pre" > button>  
<button id="btn-next" > button>  
div>

    body>
    <script>
         
    var btn1 = document.getElementById("btn-play");
        btn1.onclick = function(){
              if(audio.paused){                 
                audio.play();
            }
        }
    
    
    var btn2 = document.getElementById("btn-stop");
        btn2.onclick = function(){
              if(audio.played){                 
                audio.pause();
            }
        }
        
    var music = new Array();
    music = ["MC  -  ","  -   (Live)","  -   (DJ )"];// 
    var num = 0;
    var name = document.getElementById("name");
 
    
    
    var btn3 = document.getElementById("btn-pre");
    btn3.onclick = function(){
            num = (num +2)%3;
             audio.src = music[num]+".mp3";
            name.innerHTML == music[num];
            console.log(music[num])
            audio.play();
        }
        
    
    var btn4 = document.getElementById("btn-next");
    btn4.onclick = function(){
             num = (num +1)%3;
             audio.src = music[num]+".mp3";
            name.innerHTML == music[num];
            audio.play();
        }
    
    audio.addEventListener('ended', function () {  
    btn4.onclick();
}, false);

    script>
html>

좋은 웹페이지 즐겨찾기