vue-audio-player使用和播放器改造

支持pc和移动端

支持进度条拖动

一、安装:

yarn add @liripeng/vue-audio-player 或 npm i -S @liripeng/vue-audio-player

二、全局引入

1.import AudioPlayer from '@liripeng/vue-audio-player'

2.Vue.use(AudioPlayer)

三、使用

<template>

<div class="aBOx">

<div class="audio-tex">

<span>录音的标题</span>

<span>这是一段录音的描述</span>

</div>

<audio-player :audio-list="audioList.map(elm => elm)" :before-play="handleBeforePlay"

theme-color="red" continuation="false" />

</div>

</template>

<script>

import { ref } from "vue";

export default {

setup() {

let currentAudioName = ref('')

let audioList = ref(['//downsc.chinaz.net/Files/DownLoad/sound1/201906/11670.mp3' ])

const handleBeforePlay = (next) => {

next()

}

return {

currentAudioName,

audioList,

handleBeforePlay

}

},

}

</script>

四、改造

思路:通过css进行隐藏不需要的功能,通过定位改变到想要的位置,新增功能通过定位进行遮罩

  1. 改造前

  1. 改造后

  1. 代码:

<template>

<div class="aBOx">

<div class="audio-tex">

<span>录音的标题</span>

<span>这是一段录音的描述</span>

</div>

<audio-player :audio-list="audioList.map(elm => elm)" :before-play="handleBeforePlay"

theme-color="rgb(255,255,255,.1)" continuation="false" />

</div>

</template>

<script>

import { ref } from "vue";

export default {

setup() {

let currentAudioName = ref('')

let audioList = ref(['//downsc.chinaz.net/Files/DownLoad/sound1/201906/11670.mp3'])

const handleBeforePlay = (next) => {

next()

}

return {

currentAudioName,

audioList,

handleBeforePlay

}

},

}

</script>

<style>

.aBOx {

width: 95%;

height: 100px;

background: white;

border: 1px solid #ccc;

border-radius: 5px;

position: relative;

}

.audio-tex {

height: 60%;

width: 80%;

color: black;

position: absolute;

left: 20%;

top: 8%;

display: flex;

flex-direction: column;

justify-content: space-around;

}

.audio-tex>span:nth-child(1) {

font-size: 15px;

color: black;

font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;

}

.audio-tex>span:nth-child(2) {

font-size: 13px;

color: #ccc;

}

.audio-player {

height: 100% !important;

width: 100% !important;

display: flex;

flex-direction: column;

}

.audio__btn-wrap {

width: 90% !important;

height: 70% !important;

}

.audio__play-start {

position: absolute;

left: 0px;

top: 20%;

width: 15% !important;

height: 100% !important;

display: flex;

align-items: center;

justify-content: center;

color: yellowgreen !important;

}

.audio__play-pause {

position: absolute;

left: 0px;

top: 20%;

width: 15% !important;

height: 100% !important;

display: flex;

align-items: center;

justify-content: center;

color: yellowgreen !important;

}

.audio__play-rate {

display: none !important;

}

.audio__play-prev {

display: none !important;

}

.audio__play-next {

display: none !important;

}

.audio__play-volume-icon-wrap {

display: none !important;

}

.audio__progress-wrap {

width: 90% !important;

height: 10px !important;

margin-left: 20px;

height: 2px !important;

}

.audio__progress {

background: yellowgreen !important;

height: 2px;

}

.audio__progress-point {

display: none;

}

.audio__time-wrap {

width: 92% !important;

height: 20px !important;

margin-left: 20px;

}

</style>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值