打造属于自己的音乐播放

打造属于自己的音乐播放器:

html 代码

<!DOCTYPE html>
<html lang="zn">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>打造属于自己的音乐播放器</title>
        <link rel="stylesheet" href="css/index.css">
        <link rel="shortcut icon" type="text/css" href="http://ganto.xyz/images/favicon.ico"/>
    </head>
    <body>
        <div id="box">
            <div id="app">
                <div class="header">
                    <span class="ntm"><a style="color: white;text-decoration: none;" href="#">Music</a></span>
                    <div class="search">
                        <input type="text" placeholder="请输入歌手名字" class="text" v-model="city" @keyup.enter="getjoke">
                        <input type="button" class="button" value="搜索" @click="getjoke" >
                    </div>
                    <span class="tm" title="点击隐藏"><i>右上角展开</i>×</span>
                </div>
                <ul>
                    <li class="li" :title="a.name + '-' + a.artists[0].name" v-for="(a,index) in arr" @click="fun(a.id,a.name,a.artists[0].name)">{{a.name}}-{{a.artists[0].name}}</li>
                </ul>
                <div class="section">
                    <div class="nar">
                        <span class="name">{{ name }}</span>
                        <img class="img" :src="imgUrl" alt="">
                    </div>
                    <div class="lyric">
                        <span v-for="lrc in lyric">{{ lrc.toString().substring(10,)  }}</br></span>
                    </div>
                </div>
                <audio autoplay controls loop :src="url"></audio>
            </div>
            <span class="kai" title="展开"></span>
        </div>
        <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <!-- 开发环境版本,包含了有帮助的命令行警告 -->
        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
        <script src="js/index.js"></script>
        <script>
            $(function(){
                $(".kai").hide();
                $(".tm i").hide();
                $(".tm").click(function(){
                    $("#app").slideUp(100);
                    $(".kai").fadeIn();
                });
                $(".tm").hover(function(){
                    $(".tm i").stop().slideDown();
                },function(){
                    $(".tm i").stop().slideUp();
                })
                $(".kai").click(function(){
                    $("#app").slideDown(100);
                    $(".kai").fadeOut();
                });
                var app = $("#app"),
                    header = $(".header");
                var disX,
                    disY;
                header.mousedown(function(e){
                    disX = e.pageX - parseInt(app.offset().left);
                    disY = e.pageY - parseInt(app.offset().top);
                    document.onmousemove = function(e){
                        var event = e || window.event;
                        app.css({"left":e.pageX - disX + "px", "top":e.pageY - disY + "px"});
                    }
                    document.onmouseup = function(){
                        document.onmousemove = null;
                    }
                    
                })
                $(".github").mousedown(function(e){
                    if(e.button == 2){
                        $(this).fadeOut();
                    }
                })
            })
        </script>
    </body>
</html>

js 代码

/**
 * 1. 歌曲搜索接口,
 *    请求地址是: https://autumnfish.cn/Search
 *    请求方式是:get,
 *    请求的参数是keywords(查询关键字)
 *    响应内容,歌曲搜索结果
 * 2. 歌曲url获取接口
 *    请求地址是"https://autumnfish.cn/song/url"
 *    请求方法是get,
 *    请求参数是id
 *    响应内容:歌曲url地址
 **/
var app = new Vue({
    el:"#app",
    data:{
       city:"",
       arr:[],
       url:"",
       imgUrl:"",
       name:"",
       lyric:""
    },
    methods:{
        getjoke:function(){
            var that = this;
            axios.get("https://autumnfish.cn/search?keywords="+this.city).then(function(response){
                that.arr = response.data.result.songs;
            }).catch(function(error){
                console.log(error);
            });
        },
        fun:function(i,a,b){
            this.name = a+ "-" +b;
            var that = this;
            
            axios.get("https://autumnfish.cn/song/url?id="+i).then(function(response){
                that.url = response.data.data[0].url;
            }).catch(function(error){
                console.log(error);
            })
            axios.get("https://autumnfish.cn/song/detail?ids="+i).then(function(response){
                that.imgUrl = response.data.songs[0].al.picUrl;
                var box = document.getElementById("box");
                box.style.backgroundImage = "url("+that.imgUrl+")";
            }).catch(function(error){
                console.log(error);
            });
            axios.get("https://autumnfish.cn/lyric?id="+i).then(function(response){
                that.lyric = response.data.lrc.lyric.split("\n");
            }).catch(function(error){
                console.log(error);
            });
        },
    }
});

css 样式

*{
    margin: 0;
    padding: 0;
}
body{
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
}
#box{
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    transition: all 1s;
    display: flex;
    justify-content: center;
    align-items: center;
}
#app{
    width: 800px;
    height: 500px;
    max-width: 800px;
    max-height: 500px;
    box-shadow: 0px 0px 100px black;
    position: absolute;
    border-radius: 5px;
    overflow: hidden;
}
.header{
    width: 100%;
    height: 30px;
    background: #2ab2ab;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header img{
    width: 20px;
    height: 20px;
    cursor: pointer;
}
.header span{
    color: white;
    font-weight: 900;
    cursor: pointer;
}
.search{
    border-radius: 20px;
    background-color: rgba(255, 255, 255, .5);
    height: 30px;
}
.search .text{
    height: 30px;
    border: 0;
    background: rgba(0, 0, 0, 0);
    outline: none;
    margin-left: 10px;
    font-size: 12px;
    color: white;
}
.search .button{
    display: inline-block;
    width: 40px;
    height: 30px;
    border: 0;
    cursor: pointer;
    background: rgba(0, 0, 0, 0);
    transition: all 1s;
    color: white;
    border-radius: 20px;
    outline: none;
}
.search .button:hover{
    color: white;
    background-color: royalblue;
}
audio{
    width: 100%;
    height: 40px;
    position: absolute;
    bottom: 0;
    background-color: #eeeeee;
    outline: none;
    z-index: 9;
}
ul{
    list-style: none;
    width: 200px;
    height: 430px;
    max-height: 430px;
    background-color: royalblue;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}
ul::-webkit-scrollbar{
    display: none;
}
ul li{
    height: 17px;
    cursor: pointer;
    padding: 8px 10px;
    margin: 10px;
    border-radius: 4px;
    color: white;
    text-align: right;
    transition: all 1s;
    font-size: 13px;

    white-space: nowrap;  
    text-overflow:ellipsis;
    overflow:hidden;
}
ul li:hover{
    background: #2ab2ab;
}
li:nth-of-type(odd) {
    background: rgba(255, 255, 255, .3);
}
li:nth-of-type(even) {
    background: rgba(255, 255, 255, .1);
}
.section{
    width: 600px;
    height: 430px;
    background: royalblue;
    position: absolute;
    right: 0;
    top: 30px;
    overflow: hidden;
    /* display: flex;
    justify-content: center; */
}
.section .nar{
    width: 390px;
    position: absolute;
    top: 15px;
    text-align: center;
}
.section img{
    width: 150px;
    height: 150px;
    border-radius: 4px;
}

.section .name{
    display: block;
    color: wheat;
    z-index: 99;
    font-weight: 900;
    text-shadow: 2px 2px 5px wheat;
    padding: 20px;
}

.section .lyric{
    width: 180px;
    height: 400px;
    position: absolute;
    right: 0;
    padding: 0 10px;
    font-size: 12px;
    color: wheat;
    overflow-y: auto;
    margin: 15px;
}
.section .lyric::-webkit-scrollbar{
    display: none;
}
.section .lyric span{
    display: block;
    margin: 4px 0;

}
.kai{
    display: inline-block;
    width: 30px;
    height: 30px;
    position: fixed;
    border-radius: 50%;
    top: 10px;
    right: 10px;
    box-sizing: border-box;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    font-weight: 900;
    font-family: 幼圆;
    color: white;
    background-color: #66eeaa;
}
.kai:hover{
    box-shadow: 0 0 10px rgba(0,0,0,.5) inset;
}
.tm{
    font-size: 20px;
    font-weight: 900;
    font-family: 幼圆;
    color: white;
    position: relative;
}
.tm i{
    display: inline-block;
    width: 80px;
    height: 20px;
    font-style: normal;
    font-size: 12px;
    position: absolute;
    bottom: 0;
    left: -80px;
    text-align: center;
    line-height: 20px;
}
.github{
    position: absolute;
    bottom: 0;
    right: 0;
}

效果图

在这里插入图片描述

注释::(样式不太好看)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: 在CSDN上可以找到许多关于Android在线音乐播放器源码的资源。首先,我们可以在CSDN的搜索框中输入关键词"Android音乐播放器源码"。在搜索结果中,我们可以看到很多用户分享的音乐播放器源码。我们可以根据自己的需求选择合适的源码。一般来说,这些源码会提供基本的音乐播放功能,比如播放、暂停、上一首、下一首、进度控制等。一些高级的源码可能会提供更多功能,比如歌词显示、音效调节、扫描本地音乐库等功能。在CSDN上,我们可以参考其他开发者的源码,并从中学习到一些编程技巧和实现细节。这样可以帮助我们在自己的项目中快速实现一个功能完善的音乐播放器。另外,CSDN还有很多关于Android音乐播放器开发的教程,可以帮助我们了解整个开发过程,并提供一些实用的开发技巧和经验。总之,在CSDN上找到合适的Android音乐播放器源码,是快速实现一个功能齐全的音乐播放器的有效方法。 ### 回答2: Android是一款开源的移动操作系统,许多开发者都在该平台上开发各种应用程序。其中,音乐播放器是非常受欢迎的一种应用。CSDN是一个面向开发者的知识分享平台,上面有丰富的技术文档和源代码资源。 在CSDN上,可以找到许多人分享的Android在线音乐播放器源码。这些源码基本上都是开放的,可以供人们学习和借鉴。使用这些源码,我们可以快速了解音乐播放器的核心功能,例如音乐播放、暂停、切换歌曲、调整音量等。此外,一些源码还可能包含了网络请求、本地音乐库扫描、歌词显示等更高级的功能。 在获取到源码后,我们可以把它导入到Android Studio这样的开发工具中,进行进一步的研究和修改。通过分析源码的实现方式,我们可以学到一些开发技巧和设计思路,提升自己的开发水平。同时,也可以根据实际需要进行修改和优化,打造属于自己的音乐播放器应用。 总之,CSDN上可以找到不少Android在线音乐播放器源码,通过学习和使用这些源码,我们可以快速搭建起一个音乐播放器应用的基本框架,并且通过修改和优化,实现更加个性化的功能。 ### 回答3: CSDN是中国最大的技术社区之一,提供了丰富的技术文章、博客和论坛。在CSDN上,可以找到许多关于Android在线音乐播放器的开源代码。 Android在线音乐播放器是一种应用程序,可以通过互联网在线播放音乐。CSDN上提供的这些源码旨在帮助开发人员快速开发功能完善的音乐播放器应用。 这些源码通常包含了音乐播放器的基本功能,如音乐搜索、播放、暂停、停止、快进、快退等。同时还可能包含播放列表管理、歌词显示、分享功能等扩展功能。这些源码使用Android开发框架,如Java语言、Android Studio等进行开发。 开发人员可以通过下载这些源码并进行相应的修改和定制,以满足自己的需求。比如可以更改界面风格、增加或删除功能,甚至与其他应用进行整合。 CSDN上的这些源码不仅可以作为学习Android开发的参考,还可以用于实际项目中的开发。开发人员可以根据自己的需求,选择合适的源码进行修改和使用,快速搭建起一个功能完善的音乐播放器应用。 总之,在CSDN上可以找到许多Android在线音乐播放器的源码,这些源码是一个很好的起点,可以帮助开发人员更快地开发出高质量的音乐播放器应用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柚子·小哥哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值