平凡 发表于 2024-1-10 13:31

雅尼精选


<style>
#mydiv { margin: 150px 0 0 calc(50% - 781px); width: 1400px; height: 780px; border: 4px solid rgba(0,0,0,.15); border-radius: 10px; background: gray url('https://pic.imgdb.cn/item/659e2ad5871b83018a5942bb.jpg') no-repeat center/cover; box-shadow: 4px 4px 16px rgba(0,0,0,.25); position: relative; display: grid; place-items: center; }
#mydiv::before { position: absolute; content: attr(data-title); left: 42%;top: 87%; font: bold 2em/2.2em sans-serif; color: snow; text-shadow: 1px 1px #000; }
#rili { padding: 6px; top: 20px; max-width: 222px; display: flex; flex-direction: row; flex-wrap: wrap; color: #eee; box-sizing: border-box; position: absolute; }
#rili::before { position: absolute; content: attr(data-bg); width: 100%; height: 100%; color: rgba(0,0,0,.25); display: grid; place-items: center; font: bold 2em sans-serif; }
#iRed { position: absolute; color: red; transition: .5s; }
#iRed:hover { font-size: 40px; font-weight: bold; }
#myplayer { position: absolute; right: 80px; bottom: 80px; cursor: pointer; animation: rotating 5s infinite linear var(--state); }
.tbox { width: 30px; height: 26px; text-align: center; font: normal 16px/26px sans-serif; cursor: pointer; z-index: 10; }
.tbox:hover { color: pink; }
.tbox:active { color: navy; }
@keyframes rotating { to { transform: rotate(360deg); } }
</style>

<div id="mydiv">
      <audio id="aud" src="https://music.163.com/song/media/outer/url?id=2103942" autoplay loop></audio>
      <div id="rili"></div>
      <img id="myplayer" src="https://pic.imgdb.cn/item/659e2a9e871b83018a587f5b.png" alt="" />
</div>

<script>

/* 音乐数组:总数不低于31个,来源于网易云音乐,或URL同一个网站前缀 + 不同后缀(需修改 playSong 函数)*/
let songs = [ ["With an Orchid","20744788"], ["Nightingale","20744782"], ["Rainmaker","2103936"], ["If I Could Tell You","20744792"], ["Never Too Late ","2103950"], ["A Walk in the Rain","20744790"], ["In The Morning Light","2103740"], ["Santorini","2103779"], ["The Rain Must Fall","20744694"], ["Playing by Heart","2103942"], ["Nostalgia (Live)","2103920"], ["Prelude (Live)","2103917"], ["Until The Last Moment","20744863"], ["Ni La Fuerza Del Destino","32694623"], ["Highland","20744791"], ["Standing in Motion (Live)","2103904"], ["Love Is All","20744779"], ["20744779","20744777"], ["Adagio in C Minor","20744774"], ["Renegade","20744775"], ["Playtime (Live)","2103909"], ["Waltz In 7/8","20744781"], ["For All Seasons (Live)","2103912"], ["Change","37239803"], ["Keys to Imagination (Live)","2103901"], ["Almost a Whisper","2103947"], ["Thirst for Life","401386462"], ["In Your Eyes","20744793"], ["At First Sight","2103944"], ["November Sky","20744787"], ["On Sacred Ground (Live)","2103906"] ];
/* 画日历并播放今天曲目 */
(function () {
      let ar = '日一二三四五六'.split('').map(c => `<div class="tbox">${c}</div>`);
      let output = ar.join('');
      let y = new Date().getFullYear(), m = new Date().getMonth();
      let days = new Date(y, m+1, 0).getDate();
      let day1st = new Date(y, m).getDay();
      let today = new Date().getDate();
      Array.from({length: days + day1st}).forEach((item,key) => {
                let idx = key < day1st ? '' : (key - day1st + 1);
                if(idx) {
                        if(idx == today) idx = `<span id="iRed">${idx}</span>`;
                        let sUrl = songs, sName = songs;
                        output += `<div class="tbox" title="${sName}" onclick="playSong(${sUrl},'${sName}');this.style.color='navy';">${idx}</div>`;
                }else{
                        output += '<div class="tbox"></div>';
                }
      });
      rili.innerHTML = output;
      rili.dataset.bg = `${y}年${m+1}月`;
      let songName = songs, songUrl = songs;
      playSong(songUrl,songName);
})();
/* 播放音频函数 :相同的url前缀 + 不同的后缀id */
function playSong(id,song) {
      let url = 'https://music.163.com/song/media/outer/url?id=' + id;
      aud.src = url;
      mydiv.dataset.title = song;
};
/* 其他相关操作 */
let mState = () => mydiv.style.setProperty('--state', aud.paused ? 'paused' : 'running');
aud.addEventListener('playing', mState, false);
aud.addEventListener('pause', mState, false);
myplayer.addEventListener('click', () => aud.paused ? aud.play() : aud.pause());

</script>

平凡 发表于 2024-1-10 13:33

点击数字更换音乐欣赏

诺北 发表于 2024-1-10 18:05

这音乐我喜欢;P

诺北 发表于 2024-1-10 18:06

小凡凡挑的曲子我都挺感冒;P

平凡 发表于 2024-1-10 18:09

诺北 发表于 2024-1-10 18:05
这音乐我喜欢

三十一首曲子,你喜欢哪首:lol

平凡 发表于 2024-1-10 18:10

诺北 发表于 2024-1-10 18:06
小凡凡挑的曲子我都挺感冒

我这儿有三九感冒灵;P

大鹏 发表于 2024-1-10 20:52

乐美图美,喜欢!

蓝魔 发表于 2024-1-10 22:50

欣赏一下,谢谢。

阳光痕迹 发表于 2024-1-10 23:55

先送个花,静等打开

平凡 发表于 2024-1-11 08:51

大鹏 发表于 2024-1-10 20:52
乐美图美,喜欢!

大鹏早上好
页: [1] 2 3
查看完整版本: 雅尼精选