uniapp getBackgroundAudioManager 微信小程序后台音频播放器组件及实现

一、组件imt-audio.vue<template> <view class="imt-audio"> <view class="audio-wrapper"> <view class="audio-number">{{format(current)}}</view> <slider class="audio-slider" :activeColor="color" block-size="16" :value=
摘要由CSDN通过智能技术生成

前端样式展示(可后台播放)

   

一、组件

imt-audio.vue

<template>
	<view class="imt-audio">
		<view class="audio-wrapper">
			<view class="audio-number">{
  {format(current)}}</view>
			<slider class="audio-slider" :activeColor="color" block-size="16" :value="current" :max="duration" @changing="seek=true,current=$event.detail.value"
			 @change="seek=true,clickSeek($event.detail.value)"></slider>
			<view class="audio-number">{
  {format(duration)}}</view>
		</view>
		<view class="audio-control-wrapper" :style="{color}">
			<view class="audio-control audio-control-prev" v-if="control" :style="{borderColor:color}" @click="prev">&#xe601;</view>
			<view class="audio-control audio-control-switch" :class="{audioLoading:loading}" :style="{borderColor:color}" @click="this.paused?this.clickPlay():this.clickPaused()">{
  {loading?'&#xe600;':(paused?'&#xe865;':'&#xe612;')}}</view>
			<view class="audio-control audio-control-next" v-if="control" :style="{borderColor:color}" @click="next">&#xe601;</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// audio: uni.createInnerAudioContext(),
				audio: uni.getBackgroundAudioManager(),
				current: 0, //当前进度(s)
				duration: 0, //总时长(s)
				paused: true, //是否处于暂停状态
				loading: false, //是否处于读取状态
				seek: false ,//是否处于拖动状态
				current_tmp:0 //储存current
			}
		},
		props: {
			src: String, //音频链接
			name: String, //音频链接
			img: String, //音频链接
  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值