基於 HTML5 `

const setting = {
newSong: {target: 'newSong', type: '1', firstCount: 6, Count: 5},
songCharts: {target: 'songCharts', type: '1', firstCount: 2, Count: 4},
singer: {target: 'singer', type: '1', firstCount: 8, Count: 7},
radioStation: {target: 'radioStation', type: '1', firstCount: 9, Count: 2}
};
const modules = {};
// 默認載入新歌
modules.newSong = new Zzx(setting.newSong);
$('.menu_tagList li').on('click', function() {
const id = $(this).attr('id');
if (setting[id]) {
if (!modules[id]) modules[id] = new Zzx(setting[id]);
else modules[id].init();
$('.menu_hover').removeClass('menu_hover');
$(this).addClass('menu_hover');
}
});
const myControl = new Control({
audio: document.getElementById('myMusic'), // <audio> 元素
playModeNode: $('#modeButton'), // 播放模式按鈕
playBtn: $('#playButton'), // 主播放/暫停鈕
playTitle: $('#musicTitle'), // 歌曲標題容器
singerHead: $('#singerHead'), // 專輯圖容器
progressWrap: $('#progressWrap'), // 進度條軌道
progress: $('#progress'), // 進度條塊
oWinObj: $('#oWindow'), // 彈窗容器
allTimeNode: $('#totleTime'), // 總時長顯示
currentTimeNode: $('#currentTime') // 當前時間顯示
});
ZzxMusic(); // 啟動
專案依賴 WebKit 私有 CSS (`-webkit-`)、觸控事件 (`touchstart/move/end`)、`
此專案展示 HTML5 多媒體 API 在移動端音樂場景的實戰威力,架構清晰可作為進階播放器開發藍本。