在线体验地址 原文可体验
1,安装
npm install apple-music-player
或
yarn add apple-music-player
2,在main.ts中引入
import {
createApp } from 'vue'
import App from './App.vue'
import AppleMusicPlayer from 'apple-music-player'
createApp(App).use(AppleMusicPlayer).mount('#app')
3,页面中使用
<template>
<div style="padding-top:20%;display: flex;
justify-content: center;
align-items: center;">
<!-- 一般需要有一个div包着,设置div的宽高,播放器跟随父级宽高-->
<div style="height: 180px;width: 500px;border:1px solid #ccc;padding: 20px">
<AppleMusicPlayer progressColor="rgba(211, 16, 16, 0.1)" diskHW="110px" :musicList="musicList" :darkTheme="darkTheme" :offsetY="25" >
<!-- 这些可以换成图标按钮 -->
<template #next>
下一首
</template>
<template #last>
上一首
</template>
<template #pause>
暂停
</template>
<template #play>
播放
</template>
</AppleMusicPlayer>
</div>
</div>
</template>
<script lang="ts" setup>
import {
ref} from 'vue'
//主题
const darkTheme=ref(false)
//歌曲列表
const musicList=[
{
title:'好运来',img:'https://www.vae.zhangweicheng.xyz/VAE_Article_ShouTu/vae/6802ac85-9f22-4cc4-b812-87238f103c36.jpg',src:'https://www.vae.zhangweicheng.xyz/music/%E7%A5%96%E6%B5%B7%20-%20%E5%A5%BD%E8%BF%90%E6%9D%A5.mp3',lyric:'[00:00.00]好运来-祖海\n' +
'[00:02.60]词:车行\n' +
'[00:05.20]曲:戚建波\n' +
'[00:07.80]好运来祝你好运来\n' +
'[00:11.19]\n' +
'[00:11.79]好运带来了喜和爱\n' +
'[00:16.15]好运来我们好运来\n' +
'[00:20.29]迎着好运兴旺发达通四海\n' +
'[00:24.78]\n' +
'[00:29.17]叠个千纸鹤再系个红飘带\n' +
'[00:32.72]\n' +
'[00:33.23]愿善良的人们天天好运来\n' +
'[00:37.36]你勤劳生活美你健康春常在\n' +
'[00:41.71]你一生的忙碌为了笑逐颜开\n' +