自制系列二改进版它来了,它改进了对应的按钮,让大家看起来更加完善美观!

如果在制作过程中有如何问题你都可以私信我,我会答复你的。

下面将是制作步骤了:

先建好目录如下:

source文件夹里存放如下:

下面就是把代码复制到相应的目录中:

QQ音乐播放器.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <link rel="stylesheet" type="text/css" href="css/jquery.mCustomScrollbar.css"/>
        <link rel="stylesheet" type="text/css" href="css/1.css"/>
        <script src="js/jquery-1.12.4.js"></script>
        <script src="js/jquery.mCustomScrollbar.concat.min.js"></script>
        <script src="js/2.js"></script>
        <script src="js/3.js"></script>
        <script src="js/1.js"></script>
    </head>
    <body>
        <div class="header">
            <h1 class="logo"><a href="#"></a></h1>
            <ul class="register">
                <li>登录</li>
                <li>设置</li>
            </ul>
        </div>
        <div class="content">
            <div class="content_in">
                <div class="content_left">
                    <div class="content_toolbar">
                        <span><i></i>收藏</span>
                        <span><i></i>添加到</span>
                        <span><i></i>下载</span>
                        <span><i></i>删除</span>
                        <span><i></i>清空列表</span>
                    </div>
                    <div class="content_list" data-mcs-theme="minimal-dark">
                        <ul>
                            <li class="list_title">
                                <div class="list_check"><i></i></div>
                                <div class="list_number"></div>
                                <div class="list_name">歌曲</div>
                                <div class="list_singer">歌手</div>
                                <div class="list_time">时长</div>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="content_right">
                    <div class="song_info">
                        <a href="javascript:;" class="song_info_pic">
                            <img src="img/lnj.png" >
                        </a>
                        <div class="song_info_name">歌曲名称:
                            <a href="javascript:;">后来</a>
                        </div>
                        <div class="song_info_singer">歌手名:
                            <a href="javascript:;">刘若英</a>
                        </div>
                        <div class="song_info_ablum">专辑名:
                            <a href="javascript:;">我等你</a>
                        </div>
                    </div>
                    <ul class="song_lyric">
                        <li class="cur">第一条歌词</li>
                        <li>第二条歌词</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="footer">
            <div class="footer_in">
                <a href="javascript:;" class="music_pre"></a>
                <a href="javascript:;" class="music_play"></a>
                <a href="javascript:;" class="music_next"></a>
                <div class="music_progress_info">
                    <div class="music_progress_top">
                        <span class="music_progress_name">后来 / 刘若英</span>
                        <span class="music_progress_time">00:00 / 04:25</span>
                    </div>
                    <div class="music_progress_bar">
                        <div class="music_progress_line">
                            <div class="music_progress_dot"></div>
                        </div>
                    </div>
                </div>
                <a href="javascript:;" class="music_mode"></a>
                <a href="javascript:;" class="music_fav"></a>
                <a href="javascript:;" class="music_down"></a>
                <a href="javascript:;" class="music_comment"></a>
                <a href="javascript:;" class="music_only"></a>
                <div class="music_voice_info">
                    <a href="javascript:;" class="music_voice_icon"></a>
                    <div class="music_voice_bar">
                        <div class="music_voice_line">
                            <div class="music_voice_dot"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="mask_bg"></div>
        <div class="mask"></div>
        <audio src="" ></audio>
    </body>
</html>

1.css

*{
    margin: 0;
    padding: 0;
}
html,body{
    width: 100%;
    height: 100%;
    font-size: 14px;
}
.header{
    width: 100%;
    height: 45px;
/*     background: red; */
}
.header .logo{
    float: left;
    margin-top: 5px;
    margin-left: 20px;
    opacity: 0.5;
}
.header .logo:hover{
    opacity: 1;
}
.header .logo a{
    display: inline-block;
    width: 115px;
    height: 37px;
    background: url("../img/logo.png") no-repeat 0 0;
}
.header .register{
    float: right;
    line-height: 45px;
}
.header .register li{
    list-style: none;
    float: left;
    margin-right: 20px;
    color: #fff;
    opacity: 0.5;
}
.header .register li:hover{
    opacity: 1;
}
.content{
    width: 100%;
    height: 620px;
/*     background: blue; */
}
.content .content_in{
    width: 1200px;
    height: 100%;
/*     background: deeppink; */
    margin: 0 auto;
}
.content_in .content_left{
    float: left;
    width: 800px;
    height: 100%;
/*     background: pink; */
}
.content_left .content_toolbar{
    width: 100%;
    height: 40px;
/*     background: #000; */
}
.content_toolbar span{
    display: inline-block;
    width: 122px;
    height: 100%;
    line-height: 40px;
    text-align: center;
    border: 1px solid #fff;
    box-sizing: border-box;
    border-radius: 5px;
    color: #fff;
    opacity: 0.5;
}
.content_toolbar span i{
    display: inline-block;
    width: 40px;
    height: 40px;
    /* background: red no-repeat 0 0; */
    margin-right: 15px;
    vertical-align: -15px;
}
.content_toolbar span:nth-child(1){
    background: url(../img/3.png) no-repeat 20px 0;
}
.content_toolbar span:nth-child(2){
    background: url(../img/19.png) no-repeat 20px 0;
}
.content_toolbar span:nth-child(3){
    background: url(../img/8.png) no-repeat 20px 0;
}
.content_toolbar span:nth-child(4){
    background: url(../img/2.png) no-repeat 20px 0;
}
.content_toolbar span:nth-child(5){
    background: url(../img/20.png) no-repeat 20px 0;
}
.content_toolbar span i:hover{
    opacity: 1;
}
.content_left .content_list{
    width: 100%;
    height: 420px;
/*     background: purple; */
    overflow: auto;
}
.content_list li{
    list-style: none;
    width: 100%;
    height: 50px;
/*     background: orangered; */
    border-bottom: 1px solid rgba(255,255,255,0.5);
    box-sizing: border-box;
    user-select: none;
}
.content_list li div{
    float: left;
    color: rgba(255,255,255,0.5);
    line-height: 50px;
/*     opacity: 0.5; */
}
.content_list .list_check{
    width: 50px;
    height: 100%;
/*     background: #000; */
    text-align: center;
}
.content_list .list_check i{
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid #fff;
    opacity: 0.5;
}
.content_list .list_checked i{
    background: red no-repeat -60px -80px;
    opacity: 1;
}
.content_list .list_number{
    width: 20px;
    height: 100%;
/*     background: green; */
}
.content_list .list_number2{
    color: transparent !important;
    background: deeppink no-repeat 0 center;
}
.content_list .list_name{
    width: 50%;
    height: 100%;
/*     background: #ccc; */
}
.list_name .list_meau{
    margin-top: 5px;
    float: right;
    margin-right: 20px;
    display: none;
}
.list_meau a{
    display: inline-block;
    width: 40px;
    height: 40px;
    background: red no-repeat 0 0;
    opacity: 0.5;
}
.list_meau a:hover{
    opacity: 1;
}
.list_meau a:nth-child(1){
    background: url(../img/4.png) no-repeat 0 0;
}
.list_meau a:nth-child(2){
    background: url(../img/19.png) no-repeat 0 0;
}
.list_meau a:nth-child(3){
    background: url(../img/8.png) no-repeat 0 0;
}
.list_meau a:nth-child(4){
    background: url(../img/13.png) no-repeat 0 0;
}
.list_meau .list_meau_play2{
    background: url(../img/1.png) no-repeat 0 0 !important;
}
.content_list .list_singer{
    width: 20%;
    height: 100%;
/*     background: pink; */
}
.content_list .list_time a{
    display: inline-block;
    width: 36px;
    height: 36px;
    background: url(../img/2.png) no-repeat 0 0;
    float: left;
    margin-top: 5px;
    display: none;
    opacity: 0.5;
}
.content_list .list_time a:hover{
    opacity: 1;
}
.content_in .content_right{
    float: right;
    width: 400px;
    height: 100%;
    user-select: none;
/*     background: #ccc; */
}
.content_right .song_info{
    text-align: center;
    color: rgba(255,255,255,0.5);
    line-height: 30px;
}
.song_info .song_info_pic{
    display: inline-block;
    background: red no-repeat 0 0;
    width: 201px;
    height: 180px;
    text-align: left;
}
/* .song_info_pic img{
    width: 180px;
    height: 180px;
} */
.song_info div a{
    text-decoration: none;
    color: #fff;
    opacity: 0.5;
}
.song_info div a:hover{
    opacity: 1;
}
.content_right .song_lyric{
/*     background: green; */
    text-align: center;
    margin-top: 30px;
}
.content_right .song_lyric li{
    list-style: none;
    line-height: 30px;
    font-weight: bold;
    color: rgba(255,255,255,0.5);
}
.content_right .song_lyric .cur{
    color: #31c27c;
}
.footer{
    width: 100%;
    height: 60px;
/*     background: deeppink; */
    position: absolute;
    left: 0;
    bottom: 0;
}
.footer .footer_in{
    width: 1200px;
    height: 100%;
/*     background: plum; */
    margin: 0 auto;
    user-select: none;
}
.footer_in a{
    display: inline-block;
    text-decoration: none;
    color: #fff;
    background: red no-repeat 0 0;
    margin-left: 5px;
}
.footer_in .music_pre{
    width: 40px;
    height: 40px;
    background: url(../img/5.png) no-repeat 0 0;
}
.footer_in .music_play{
    width: 40px;
    height: 40px;
    background: url(../img/4.png) no-repeat 0 0;
}
.footer_in .music_play2{
    width: 40px;
    height: 40px;
    background: url(../img/1.png) no-repeat 0 0;
}
.footer_in .music_next{
    width: 40px;
    height: 40px;
    background: url(../img/6.png) no-repeat 0 0;
}
.footer_in .music_progress_info{
    display: inline-block;
    width: 670px;
    height: 40px;
    background: green;
    position: relative;
    /* top: 10px; */
}
.music_progress_info .music_progress_top{
    width: 100%;
    height: 30px;
    line-height: 30px;
/*     background: #000; */
    color: #fff;
}
.music_progress_top .music_progress_name{
    float: left;
    opacity: 0.5;
}
.music_progress_top .music_progress_name:hover{
    opacity: 1;
}
.music_progress_top .music_progress_time{
    float: right;
    opacity: 0.5;
}
.music_progress_info .music_progress_bar{
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.5);
    margin-top: 5px;
    position: relative;
}
.music_progress_bar .music_progress_line{
    width: 0;
    height: 100%;
    background: #fff;
}
.music_progress_line .music_progress_dot{
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: -5px;
    left: 0;
}
.footer_in .music_mode{
    width: 40px;
    height: 40px;
    background: url(../img/9.png) no-repeat 0 0;
}
.footer_in .music_mode2{
    width: 40px;
    height: 40px;
    background: url(../img/13.png) no-repeat 0 0;
}
.footer_in .music_mode3{
    width: 40px;
    height: 40px;
    background: url(../img/14.png) no-repeat 0 0;
}
.footer_in .music_mode4{
    width: 40px;
    height: 40px;
    background: url(../img/15.png) no-repeat 0 0;
}
.footer_in .music_fav{
    width: 40px;
    height: 40px;
    background: url(../img/3.png) no-repeat 0 0;
}
.footer_in .music_fav2{
    width: 40px;
    height: 40px;
    background: url(../img/12.png) no-repeat 0 0;
}
.footer_in .music_down{
    width: 40px;
    height: 40px;
    background: url(../img/8.png) no-repeat 0 0;
}
.footer_in .music_comment{
    width: 40px;
    height: 40px;
    background: url(../img/16.png) no-repeat 0 0;
}
.footer_in .music_only{
    width: 40px;
    height: 40px;
    background: url(../img/17.png) no-repeat 0 0;
}
.footer_in .music_only2{
    width: 40px;
    height: 40px;
    background: url(../img/18.png) no-repeat 0 0;
}
.footer_in .music_voice_info{
    display: inline-block;
    width: 100px;
    height: 40px;
    /* background: green; */
    position: relative;
    /* top: 10px; */
}
.music_voice_info .music_voice_icon{
    width: 40px;
    height: 40px;
    background: url(../img/7.png) no-repeat 0 0;
    position: absolute;
    left: 0;
    /* top: 10px; */
}
.music_voice_info .music_voice_icon2{
    width: 40px;
    height: 40px;
    background: url(../img/11.png) no-repeat 0 0;
}
.music_voice_info .music_voice_bar{
    width: 60px;
    height: 4px;
    background: rgba(255,255,255,0.5);
    position: absolute;
    right: 0;
    top: 18px;
}
.music_voice_bar .music_voice_line{
    width: 60px;
    height: 100%;
    background: #fff;
}
.music_voice_line .music_voice_dot{
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    position: relative;
    top: -5px;
    left: 60px;
}
.mask_bg{
    position: absolute;
    left: 0;
    top: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    background: url("../img/lnj.png") no-repeat 0 0;
    background-size: cover;
    filter: blur(100px);
}
.mask{
    position: absolute;
    left: 0;
    top: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.35);
}
._mCS_1 .mCSB_scrollTools .mCSB_dragger_bar{
    width: 8px;
}

1.js

$(function(){
    //自定义滚动条
    $(".content_list").mCustomScrollbar();
    var audios = $("audio");
    var player = new Player(audios);
    var progress;
    var voiceProgress;
    //加载歌曲
    getPlayerList();
    function getPlayerList(){
        $.ajax({
            url: "./source/musiclist.json",
            dataType: "json",
            success: function(data){
                // console.log(data);
                var musicList = $(".content_list ul");
                player.musicList = data;
                $.each(data,function(index,ele){
                    var item = createMusicItem(index,ele);
                    musicList.append(item);
                });
                initMusicInfo(data[0]);
                // initMusicLyric(data[0]);
            },
            error: function(e){
                console.log(e);
            }
        });
    }
    //初始化歌曲信息
    function initMusicInfo(music){
        //获取对应的元素
        var musicImage = $(".song_info_pic img");
        var musicName = $(".song_info_name a");
        var musicSinger = $(".song_info_singer a");
        var musicAblum = $(".song_info_ablum a");
        var musicProgressName = $(".music_progress_name");
        var musicProgressTime = $(".music_progress_time");
        var musicBg = $(".mask_bg");
        //给元素赋值
        musicImage.attr("src",music.cover);
        musicName.text(music.name);
        musicSinger.text(music.singer);
        musicAblum.text(music.album);
        musicProgressName.text(music.name +" / "+music.singer);
        musicProgressTime.text("00:00 / "+music.time);
        musicBg.css("background","url('"+music.cover+"')");
    }
    //初始化歌词信息
    // function initMusicLyric(music){
    //     var lyric = new Lyric(music.link_lrc);
    //     lyric.loadLyric();
    // }
    //初始化进度条
    initProgress();
    function initProgress(){
        var progressBar = $(".music_progress_bar");
        var progressLine = $(".music_progress_line");
        var progressDot = $(".music_progress_dot");
        progress = Progress(progressBar,progressLine,progressDot);
        progress.progressClick(function(value){
            player.musicSeekTo(value);
        });
        progress.progressMove(function(value){
            player.musicSeekTo(value);
        });
        
        var voiceBar = $(".music_voice_bar");
        var voiceLine = $(".music_voice_line");
        var voiceDot = $(".music_voice_dot");
        voiceProgress = Progress(voiceBar,voiceLine,voiceDot);
        voiceProgress.progressClick(function(value){
            player.musicVoiceSeekTo(value);
        });
        voiceProgress.progressMove(function(value){
            player.musicVoiceSeekTo(value);
        });
    }
    //初始化事件监听
    initEvents();
    function initEvents(){
        //监听歌曲移入移出
        $(".content_list").delegate(".list_music","mouseenter",function(){
            //显示子菜单
            $(this).find(".list_meau").stop().fadeIn(100);
            $(this).find(".list_time a").stop().fadeIn(100);
            //隐藏时长
            $(this).find(".list_time span").stop().fadeOut(100);
        });
        $(".content_list").delegate(".list_music","mouseleave",function(){
            //隐藏子菜单
            $(this).find(".list_meau").stop().fadeOut(100);
            $(this).find(".list_time a").stop().fadeOut(100);
            //显示时长
            $(this).find(".list_time span").stop().fadeIn(100);
        });
        //监听复选框的点击
        $(".content_list").delegate(".list_check","click",function(){
            $(this).toggleClass("list_checked");
        });
        //添加子菜单播放按钮
        var musicPlay = $(".music_play");
        $(".content_list").delegate(".list_meau_play","click",function(){
            var item = $(this).parents(".list_music");
            // console.log(item.get(0).index);
            // console.log(item.get(0).music);
            //切换播放图标
            $(this).toggleClass("list_meau_play2");
            //复原其他播放图标
            item.siblings().find(".list_meau_play").removeClass("list_meau_play2");
            if($(this).attr("class").indexOf("list_meau_play2") != -1){
                //当前子菜单播放按钮是播放状态
                musicPlay.addClass("music_play2");
                //让文字高亮
                item.find("div").css("color","#fff");
                item.siblings().find("div").css("color","rgba(255,255,255,0.5)");
            }else{
                //当前子菜单播放按钮不是播放状态
                musicPlay.removeClass("music_play2");
                //让文字不高亮
                item.find("div").css("color","rgba(255,255,255,0.5)");
            }
            // musicPlay.toggleClass("music_play2");
            //切换序号状态
            item.find(".list_number").toggleClass("list_number2");
            item.siblings().find(".list_number").removeClass("list_number2");
            //播放音乐
            player.playMusic(item.get(0).index,item.get(0).music);
            //切换歌曲信息
            initMusicInfo(item.get(0).music);
        });
        //监听底部播放按钮的点击
        musicPlay.click(function(){
            //判断有没有播放过音乐
            if(player.currentIndex == -1){
                //没有播放
                $(".list_music").eq(0).find(".list_meau_play").trigger("click");
            }else{
                //播放过
                $(".list_music").eq(player.currentIndex).find(".list_meau_play").trigger("click");
            }
        });
        //监听底部上一首按钮的点击
        $(".music_pre").click(function(){
            $(".list_music").eq(player.preIndex()).find(".list_meau_play").trigger("click");
        });
        //监听底部下一首按钮的点击
        $(".music_next").click(function(){
            $(".list_music").eq(player.nextIndex()).find(".list_meau_play").trigger("click");
        });
        //监听删除按钮点击
        $(".content_list").delegate(".list_meau_del","click",function(){
            //找到被点击的音乐
            var item = $(this).parents(".list_music");
            //判断当前删除的音乐是否在播放
            if(item.get(0).index == player.currentIndex){
                $(".music_next").trigger("click");
            }
            item.remove();
            player.changeMusic(item.get(0).index);
            //重新排序
            $(".list_music").each(function(index,ele){
                ele.index = index;
                $(ele).find(".list_number").text(index + 1);
            });
        });
        //监听播放进度
        player.musicTimeUpdate(function(currentTime,duration,timeStr){
            //同步时间
            $(".music_progress_time").text(timeStr);
            //同步进度条
            //计算播放比例
            var value = currentTime / duration * 100;
            progress.setProgress(value);
        });
        //监听声音按钮的点击
        $(".music_voice_icon").click(function(){
            //图标切换
            $(this).toggleClass("music_voice_icon2");
            //声音切换
            if($(this).attr("class").indexOf("music_voice_icon2") != -1){
                //变为没有声音
                player.musicVoiceSeekTo(0);
            }else{
                //变为有声音
                player.musicVoiceSeekTo(1);
            }
        });
    }
    
    //定义一个方法创建一条音乐
    function createMusicItem(index,music){
        var item = $("<li class=\"list_music\">"+
                                "<div class=\"list_check\"><i></i></div>"+
                                "<div class=\"list_number\">"+(index+1)+"</div>"+
                                "<div class=\"list_name\">"+music.name+""+
                                    "<div class=\"list_meau\">"+
                                        "<a href=\"javascript:;\" title=\"播放\" class=\"list_meau_play\"></a>"+
                                        "<a href=\"javascript:;\" title=\"添加\"></a>"+
                                        "<a href=\"javascript:;\" title=\"下载\"></a>"+
                                        "<a href=\"javascript:;\" title=\"分享\"></a>"+
                                    "</div>"+
                                "</div>"+
                                "<div class=\"list_singer\">"+music.singer+"</div>"+
                                "<div class=\"list_time\">"+
                                    "<span>"+music.time+"</span>"+
                                    "<a href=\"javascript:;\" title=\"删除\" class=\"list_meau_del\"></a>"+
                                "</div>"+
                            "</li>");
        item.get(0).index = index;
        item.get(0).music = music;
        return item;
    }
    
});

2.js

//JS的面向对象
(function(window){
    function Player(audios){
        return new Player.prototype.init(audios);
    }
    Player.prototype = {
        constructor: Player,
        musicList: [],
        init: function(audios){
            this.audios = audios;
            this.audio = audios.get(0);
        },
        currentIndex: -1,
        playMusic: function(index,music){
            //判断是否是同一首音乐
            if(this.currentIndex == index){
                //同一首音乐
                if(this.audio.paused){
                    this.audios.attr("src",music.link_url);
                    this.audio.play();
                }else{
                    this.audio.pause();
                }
            }else{
                this.currentIndex = index;
                // console.log(this.currentIndex);
                //不是同一首
                this.audios.attr("src",music.link_url);
                this.audio.play();
            }
        },
        preIndex:function(){
            var index = this.currentIndex - 1;
            if(index < 0){
                index = this.musicList.length - 1;
            }
            return index;
        },
        nextIndex:function(){
            var index = this.currentIndex + 1;
            if(index > this.musicList.length - 1){
                index = 0;
            }
            return index;
        },
        changeMusic:function(index){
            //删除对应的数据
            this.musicList.splice(index,1);
            //判断当前删除的音乐是否是正在播放音乐的前面
            if(index < this.currentIndex){
                this.currentIndex = this.currentIndex - 1;
            }
        },
        // getMusicDuration:function(){
        //     return this.audio.duration;
        // },
        // getMusicCurrentTime:function(){
        //     return this.audio.currentTime;
        // },
        musicTimeUpdate:function(callBack){
            var $this = this;
            this.audios.on("timeupdate",function(){
                var duration = $this.audio.duration;
                var currentTime = $this.audio.currentTime;
                var timeStr = $this.formatDate(currentTime,duration);
                callBack(currentTime,duration,timeStr);
            });
        },
        formatDate:function(currentTime,duration){
            var endMin = parseInt(duration / 60);
            var endSec = parseInt(duration % 60);
            if(endMin < 10){
                endMin = "0" + endMin;
            }
            if(endSec < 10){
                endSec = "0" + endSec;
            }
            var startMin = parseInt(currentTime / 60);
            var startSec = parseInt(currentTime % 60);
            if(startMin < 10){
                startMin = "0" + startMin;
            }
            if(startSec < 10){
                startSec = "0" + startSec;
            }
            return startMin+":"+startSec+" / "+endMin+":"+endSec;
        },
        musicSeekTo:function(value){
            if(isNaN(value)) return;
            this.audio.currentTime = this.audio.duration * value;
        },
        musicVoiceSeekTo:function(value){
            if(isNaN(value)) return;
            if(value < 0 || value > 1) return;
            //0~1
            this.audio.volume = value;
        }
    }
    Player.prototype.init.prototype = Player.prototype;
    window.Player = Player;
})(window);

3.js

//JS的面向对象
(function(window){
    function Progress(progressBar,progressLine,progressDot){
        return new Progress.prototype.init(progressBar,progressLine,progressDot);
    }
    Progress.prototype = {
        constructor: Progress,
        init: function(progressBar,progressLine,progressDot){
            this.progressBar = progressBar;
            this.progressLine = progressLine;
            this.progressDot = progressDot;
        },
        isMove:false,
        progressClick:function(callBack){
            var $this = this;//此时此刻的this是progress
            //监听背景点击
            this.progressBar.click(function(event){
                //获取背景距离窗口默认位置
                var normalLeft = $(this).offset().left;
                //获取点击的位置距离窗口的位置
                var eventLeft = event.pageX;
                //设置前景的宽度
                $this.progressLine.css("width",eventLeft - normalLeft);
                $this.progressDot.css("left",eventLeft - normalLeft);
                //计算进度条比例
                var value = (eventLeft - normalLeft) / $(this).width();
                callBack(value);
            });
        },
        progressMove:function(callBack){
            var $this = this;
            //获取背景距离窗口默认位置
            var normalLeft = this.progressBar.offset().left;
            var barWidth = this.progressBar.width();
            var eventLeft;
            //监听鼠标的按下
            this.progressBar.mousedown(function(){
                $this.isMove = true;
                //监听鼠标的移动
                $(document).mousemove(function(event){
                    //获取点击的位置距离窗口的位置
                    eventLeft = event.pageX;
                    var offset = eventLeft - normalLeft;
                    if(offset >= 0 && offset <= barWidth){
                        //设置前景的宽度
                        $this.progressLine.css("width",eventLeft - normalLeft);
                        $this.progressDot.css("left",eventLeft - normalLeft);
                    }
                });
            });
            //监听鼠标的抬起
            $(document).mouseup(function(){
                $(document).off("mousemove");
                $this.isMove = false;
                //计算进度条比例
                var value = (eventLeft - normalLeft) / $this.progressBar.width();
                callBack(value);
            });
        },
        setProgress:function(value){
            if(this.isMove) return;
            if(value < 0 || value > 100) return;
            this.progressLine.css({
                width: value+"%"
            });
            this.progressDot.css({
                left: value+"%"
            });
        }
    }
    Progress.prototype.init.prototype = Progress.prototype;
    window.Progress = Progress;
})(window);

4.js

//JS的面向对象
(function(window){
    function Lyric(path){
        return new Lyric.prototype.init(path);
    }
    Lyric.prototype = {
        constructor: Lyric,
        musicList: [],
        init: function(path){
            this.path = path;
        },
        loadLyric:function(){
            var $this = this;
            $.ajax({
                url: $this.path,
                dataType: "text",
                success: function(data){
                    // console.log(data);
                    $this.parseLyric(data);
                },
                error: function(e){
                    console.log(e);
                }
            });
        }
    }
    Lyric.prototype.init.prototype = Lyric.prototype;
    window.Lyric = Lyric;
})(window);

musiclist.json

[
    {
        "name":"I Lomo You",
        "singer":"王欣宇",
        "album":"I Lomo You",
        "time":"01:47",
        "link_url":"./source/ILomoYou.mp3",
        "cover":"./source/ILomoYou.png",
        "link_lrc":"I Lomo You"
    },
    {
        "name":"千灯之约",
        "singer":"王者荣耀",
        "album":"千灯之约",
        "time":"06:06",
        "link_url":"./source/千灯之约.mp3",
        "cover":"./source/千灯之约.png",
        "link_lrc":"千灯之约"
    },
    {
        "name":"西海情歌",
        "singer":"刀郎",
        "album":"刀郎III",
        "time":"05:46",
        "link_url":"./source/西海情歌.mp3",
        "cover":"./source/西海情歌.png",
        "link_lrc":"西海情歌"
    },
    {
        "name":"年轻的战场",
        "singer":"张杰",
        "album":"年轻的战场",
        "time":"04:53",
        "link_url":"./source/年轻的战场.mp3",
        "cover":"./source/年轻的战场.png",
        "link_lrc":"年轻的战场"
    },
    {
        "name":"公子向北走",
        "singer":"梦凉",
        "album":"公子向北走",
        "time":"02:16",
        "link_url":"./source/公子向北走.mp3",
        "cover":"./source/公子向北走.png",
        "link_lrc":"公子向北走"
    },
    {
        "name":"一起走的幸福",
        "singer":"橘子拿来u",
        "album":"橘子翻唱合集",
        "time":"03:07",
        "link_url":"./source/一起走的幸福.mp3",
        "cover":"./source/一起走的幸福.png",
        "link_lrc":"一起走的幸福"
    },
    {
        "name":"棉花糖",
        "singer":"黑崎子",
        "album":"棉花糖",
        "time":"03:49",
        "link_url":"./source/棉花糖.mp3",
        "cover":"./source/棉花糖.png",
        "link_lrc":"棉花糖"
    },
    {
        "name":"藏不住的心跳",
        "singer":"何三川",
        "album":"藏不住的心跳",
        "time":"03:59",
        "link_url":"./source/藏不住的心跳.mp3",
        "cover":"./source/藏不住的心跳.png",
        "link_lrc":"藏不住的心跳"
    },
    {
        "name":"有幸",
        "singer":"老光",
        "album":"有幸",
        "time":"03:39",
        "link_url":"./source/有幸.mp3",
        "cover":"./source/有幸.png",
        "link_lrc":"有幸"
    },
    {
        "name":"孤芳自赏",
        "singer":"杨小壮",
        "album":"孤芳自赏",
        "time":"04:28",
        "link_url":"./source/孤芳自赏.mp3",
        "cover":"./source/孤芳自赏.png",
        "link_lrc":"孤芳自赏"
    },
    {
        "name":"理想三旬",
        "singer":"张宇清",
        "album":"理想三旬",
        "time":"03:08",
        "link_url":"./source/理想三旬.mp3",
        "cover":"./source/理想三旬.png",
        "link_lrc":"理想三旬"
    },
    {
        "name":"会好的",
        "singer":"张艺兴",
        "album":"会好的",
        "time":"03:30",
        "link_url":"./source/会好的.mp3",
        "cover":"./source/会好的.png",
        "link_lrc":"会好的"
    },
    {
        "name":"只要平凡",
        "singer":"张杰/张碧晨",
        "album":"只要平凡",
        "time":"04:06",
        "link_url":"./source/只要平凡.mp3",
        "cover":"./source/只要平凡.png",
        "link_lrc":"只要平凡"
    },
    {
        "name":"老人与海",
        "singer":"海鸣威",
        "album":"精彩音乐汇",
        "time":"02:54",
        "link_url":"./source/老人与海.mp3",
        "cover":"./source/老人与海.png",
        "link_lrc":"老人与海"
    },
    {
        "name":"会呼吸的痛",
        "singer":"梁静茹",
        "album":"会呼吸的痛",
        "time":"04:32",
        "link_url":"./source/会呼吸的痛.mp3",
        "cover":"./source/会呼吸的痛.png",
        "link_lrc":"会呼吸的痛"
    }
]

以上就是我们需要完成的所有代码。

还有一些插件(两个js和一个css)需要自己到网上去下载,如果找不到可以私信我,我私发给你。

下面再来看看完成之后的效果图吧!

我随便截了几张图,下面我来说说可以实现的功能:

基本的播放暂停和上一首下一首毋庸置疑是没问题的,还可以实现调节音乐声音的大小、拖拉进度条等等。

而且你们可以看到,背景色是会随着歌曲的不同而改变的,是不是显得高端大气上档次呀!

最后,祝大家都可以成功制作出QQ音乐,这就是系列二改进版的全部内容了!

(优化版)简易版QQ音乐改进版(HTML+CSS+JQuery)相关推荐

  1. 每个人都能制作的简易版QQ音乐(HTML+CSS+JQuery)

    自制系列二它来了. 如果在制作过程中有如何问题你都可以私信我,我会答复你的. 今天中秋节,首先祝大家中秋节快乐! 因为没什么礼物送给大家,所以在这里给大家安利一份简易版QQ音乐的制作,过程很简单,每个 ...

  2. scala mysql连接池_Java与Scala的两种简易版连接池

    Java版简易版连接池: import java.sql.Connection; import java.sql.DriverManager; import java.util.LinkedList; ...

  3. jQuery网页版简易qq音乐

    <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8" ...

  4. qq动态页面变方格_腾讯QQ音乐9.7.5正式版更新:「歌手主页个人主页」界面全新改版...

    IT之家12月23日消息 今天,腾讯QQ音乐推送了v9.7.5正式版的更新,「歌手主页&个人主页」页面全新改版:「排行榜」新增榜单推荐,基于你的喜好为你推荐榜单:增加本地歌曲排行榜:「听歌识曲 ...

  5. 基于jQuery仿QQ音乐播放器网页版代码

    基于jQuery仿QQ音乐播放器网页版代码是一款黑色样式风格的网页QQ音乐播放器样式代码.效果图如下: 在线预览    源码下载 实现的代码. html代码: <div class=" ...

  6. qq音乐2012绿色版

    还有那永远不会忘记冰冷的qq音乐2012绿色版表情吧?我在找那个故事的人,在哪?在哪?我哭泣着,想起永远逝去的童年,想着如今的悲哀,我想我的泪水永远不会有人知道,那时青春的苦涩.一大早,赶着上火车时, ...

  7. 用html写QQ音乐首页,使用HTML5仿制的QQ音乐PC版界面

    QQ音乐界面仿制 在专业认识实习中,我们通过学习HTML超文本标记语言,提高了静态web前端页面的开发能力,下面就给大家展示一下我们小组仿制的QQ音乐官网界面,只是仿制了PC版,但是部分手机浏览器(Q ...

  8. 新的vue项目-qq音乐网页版

    找到了很多开放的api, 打算实现部分的网页版qq音乐. API集合 推荐歌单 https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecomme ...

  9. android首字母检索音乐,新增首字母检索 QQ音乐Android版更新

    QQ音乐Android版发布更新,就如何更有效的提高用户在音乐搜索方面的操作,新增"歌曲列表字母索引"功能,通过首字母快速检索帮助用户锁定心中那一首歌!同时,针对部分歌词或专辑图片 ...

最新文章

  1. docker pull拉取镜像_docker拉取镜像失败解决
  2. vue-cli启动项目运行_SpringBoot2.0 基础案例(17):自定义启动页,项目打包和指定运行环境...
  3. JavaSE基础知识(5)—面向对象(5.2类的成员)
  4. 全局变量引起的BUG
  5. Boost:基于Boost的daytime服务测试程序
  6. 成功必读本:培养人脉的106个技巧
  7. 编程实现newton插值c++_数据体操:数据处理和IDW地理插值算法
  8. java错误页面_java自定义错误页面实现方法
  9. 前馈控制、反馈控制及前馈-反馈控制的对比
  10. Refused to execute script from 'http://localhost:8080/login' because its MIME type ('text/html') is
  11. windows10 安装office2021(预装正版)经验分享
  12. wire tox_Tox-rs的漫长旅程。 第1部分
  13. python平安经_读完一本平安经是怎样的体验?
  14. 快速判断能否被某个数整除
  15. java 丢包_Java数据报之失序和丢包
  16. 【游戏动画】游戏动画总结
  17. Java 文件操作 逐行替换文件内容,加快翻译效率
  18. 案例——封装一个轮播图插件
  19. 5步教你完成小熊派开发板贴片
  20. Detectron2专栏开篇

热门文章

  1. 下载Python类库Server Error 404 - File
  2. hbase调用ImportTsv导入csv文件时报错File does not exist
  3. 零起步学无线电收发——从等幅波发射机认识振荡与发射
  4. word无法保存此文件,因为它已经在别处打开。(C:/…/STARTUP/Powerword.dot)
  5. Linux文件中查找字符串
  6. 仿魅族手机消息通知效果
  7. 从新和重新意思一样吗_“重新”和“从新”意思上有什么不同?
  8. 【领导力】《如坐针毡》逆境中的领导力
  9. BJCORE半导体划片机设备——封装的八道工序
  10. Redis内存淘汰机制