knowledge-vault/sayings/2026/2026-03-31-lingshan-is-far-...

195 lines
6.5 KiB
Markdown

---
layout: post
title: "灵山远(音乐组曲)"
date: 2026-03-31 15:19:00
author: "Wantsong"
params:
published: true
image: "https://imgs.wantsong.life/WglDINj6JY.jpg"
tags: ["Original"]
categories:
- "SONGS"
---
<div style="text-align: center;">
<div id="music-player-container">
<!-- 当前播放歌曲封面 -->
<img id="current-cover" src="https://imgs.wantsong.life/pAL1KdAvch.jpg" alt="当前播放" style="width: 320px; height: 180px; border-radius: 10px; margin-bottom: 15px;">
<!-- 当前播放歌曲标题 -->
<p id="current-title"><strong>石中火</strong></p>
<!-- 主播放器 -->
<audio id="main-player" controls style="width: 100%; max-width: 400px; margin: 15px 0;">
<source id="current-source" src="https://songs.wantsong.life/lingshan/1.mp3" type="audio/mpeg">
您的浏览器不支持音频播放。
</audio>
<!-- 播放控制按钮 -->
<div style="margin: 15px 0;">
<button id="prev-btn" onclick="previousTrack()" style="margin: 0 10px; padding: 8px 15px; background: #4a90e2; color: white; border: none; border-radius: 5px; cursor: pointer;">上一首</button>
<button id="next-btn" onclick="nextTrack()" style="margin: 0 10px; padding: 8px 15px; background: #4a90e2; color: white; border: none; border-radius: 5px; cursor: pointer;">下一首</button>
</div>
<!-- 播放列表 -->
<div style="margin-top: 20px; padding: 15px; background: #f8f9fa; border-radius: 10px; max-width: 500px; margin-left: auto; margin-right: auto;">
<h4 style="margin-top: 0; color: #333;">播放列表</h4>
<div id="playlist">
<div class="track-item active" onclick="playTrack(0)" style="padding: 8px; margin: 5px 0; background: #e3f2fd; border-radius: 5px; cursor: pointer; border-left: 4px solid #4a90e2;">
<strong>1. 石中火</strong>
</div>
<div class="track-item" onclick="playTrack(1)" style="padding: 8px; margin: 5px 0; background: white; border-radius: 5px; cursor: pointer; border-left: 4px solid transparent;">
<strong>2. 月映浮屠</strong>
</div>
<div class="track-item" onclick="playTrack(2)" style="padding: 8px; margin: 5px 0; background: white; border-radius: 5px; cursor: pointer; border-left: 4px solid transparent;">
<strong>3. 一念花开</strong>
</div>
<div class="track-item" onclick="playTrack(3)" style="padding: 8px; margin: 5px 0; background: white; border-radius: 5px; cursor: pointer; border-left: 4px solid transparent;">
<strong>4. 离合如幻</strong>
</div>
<div class="track-item" onclick="playTrack(4)" style="padding: 8px; margin: 5px 0; background: white; border-radius: 5px; cursor: pointer; border-left: 4px solid transparent;">
<strong>5. 赤诚马蹄疾</strong>
</div>
<div class="track-item" onclick="playTrack(5)" style="padding: 8px; margin: 5px 0; background: white; border-radius: 5px; cursor: pointer; border-left: 4px solid transparent;">
<strong>6. 步履即道场</strong>
</div>
</div>
</div>
</div>
</div>
<script>
// 音乐播放列表数据
const playlist = [
{
title: "石中火",
src: "https://songs.wantsong.life/lingshan/1.mp3",
cover: "https://imgs.wantsong.life/pAL1KdAvch.jpg"
},
{
title: "月映浮屠",
src: "https://songs.wantsong.life/lingshan/2.mp3",
cover: "https://imgs.wantsong.life/pAL1KdAvch.jpg"
},
{
title: "一念花开",
src: "https://songs.wantsong.life/lingshan/3.mp3",
cover: "https://imgs.wantsong.life/pAL1KdAvch.jpg"
},
{
title: "离合如幻",
src: "https://songs.wantsong.life/lingshan/4.mp3",
cover: "https://imgs.wantsong.life/pAL1KdAvch.jpg"
},
{
title: "赤诚马蹄疾",
src: "https://songs.wantsong.life/lingshan/5.mp3",
cover: "https://imgs.wantsong.life/pAL1KdAvch.jpg"
},
{
title: "步履即道场",
src: "https://songs.wantsong.life/lingshan/6.mp3",
cover: "https://imgs.wantsong.life/pAL1KdAvch.jpg"
}
];
let currentTrackIndex = 0;
const player = document.getElementById('main-player');
const currentTitle = document.getElementById('current-title');
const currentCover = document.getElementById('current-cover');
const currentSource = document.getElementById('current-source');
// 播放指定曲目
function playTrack(index) {
if (index >= 0 && index < playlist.length) {
currentTrackIndex = index;
const track = playlist[index];
// 更新播放器
currentSource.src = track.src;
currentTitle.innerHTML = '<strong>' + track.title + '</strong>';
currentCover.src = track.cover;
currentCover.alt = track.title;
player.load();
// 更新播放列表样式
updatePlaylistUI();
// 自动播放
player.play().catch(e => {
console.log('自动播放被阻止,请手动点击播放');
});
}
}
// 下一首
function nextTrack() {
const nextIndex = (currentTrackIndex + 1) % playlist.length;
playTrack(nextIndex);
}
// 上一首
function previousTrack() {
const prevIndex = (currentTrackIndex - 1 + playlist.length) % playlist.length;
playTrack(prevIndex);
}
// 更新播放列表UI
function updatePlaylistUI() {
const trackItems = document.querySelectorAll('.track-item');
trackItems.forEach((item, index) => {
if (index === currentTrackIndex) {
item.className = 'track-item active';
item.style.background = '#e3f2fd';
item.style.borderLeft = '4px solid #4a90e2';
} else {
item.className = 'track-item';
item.style.background = 'white';
item.style.borderLeft = '4px solid transparent';
}
});
}
// 监听播放结束事件,自动播放下一首
player.addEventListener('ended', nextTrack);
// 添加键盘快捷键支持
document.addEventListener('keydown', function(e) {
if (e.target.tagName.toLowerCase() !== 'input' && e.target.tagName.toLowerCase() !== 'textarea') {
switch(e.key) {
case 'ArrowLeft':
previousTrack();
e.preventDefault();
break;
case 'ArrowRight':
nextTrack();
e.preventDefault();
break;
case ' ':
if (player.paused) {
player.play();
} else {
player.pause();
}
e.preventDefault();
break;
}
}
});
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', function() {
updatePlaylistUI();
});
</script>
<style>
.track-item:hover {
background: #f0f8ff !important;
}
#music-player-container button:hover {
background: #357abd !important;
}
#playlist {
text-align: left;
}
</style>