2 lines
34 KiB
JavaScript
2 lines
34 KiB
JavaScript
|
import{_ as e,C as t,o as s,c as i,w as o,g as a,h as n,f as l,n as c,i as r,t as d,y as u,j as m,D as h,l as p,s as g,u as f,E as y,G as x,H as _,I as C,J as k,q as w,p as b,K as I,d as T,e as v,F as M,L as S,M as B,N as j,b as U,A,S as L,z as N,m as R,O as $,a as D,P as E,$ as H,Q as F,R as O,T as P,U as z,V,r as J,k as q,W}from"./index-22d2df30.js";import{_ as G}from"./uni-load-more.e389ae51.js";import{r as K}from"./uni-app.es.06715d18.js";import{e as Q,_ as Y}from"./emoji.c33868a4.js";import{s as X}from"./status.1eeec7ff.js";let Z;const ee=e({name:"syAudio",emits:["audioPlay","audioPause","audioEnd","audioCanplay","change"],data:()=>({audio_status:!1,timeTxt:"00 : 00",timeIndex:0,sliderIndex:0,maxSliderIndex:100,stringObject:e=>typeof e,innerAudioContext:t()}),props:{autoplay:{type:Boolean,default:!1},src:{type:[String,Array],default:""},isCountDown:{type:Boolean,default:!1},audioCover:{type:String,default:""},audioTitle:{type:String,default:"new Audio Title"},audioTitleColor:{type:String,default:"#333"},subheading:{type:String,default:"new Audio Subheading"},activeColor:{type:String,default:"#bf41a2"},backgroundColor:{type:String,default:"#f1c38b"}},async mounted(){if(this.innerAudioContext.src="string"==typeof this.src?this.src:this.src[0],this.autoplay){if(!this.src)return console.error("src cannot be empty,The target value is string or array");if("micromessenger"==window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i)){const e=require("../../utils/jweixin");e.config({}),e.ready((()=>{WeixinJSBridge.invoke("getNetworkType",{},(e=>{this.innerAudioContext.play(),this.countDown()}))}))}}this.innerAudioContext.onPlay((()=>{this.audio_status=!0,this.$emit("audioPlay"),setTimeout((()=>{this.maxSliderIndex=parseFloat(this.innerAudioContext.duration).toFixed(2),this.countDown()}),100)})),this.innerAudioContext.onPause((()=>{this.$emit("audioPause")})),this.innerAudioContext.onEnded((()=>{this.audio_status=!this.audio_status,this.$emit("audioEnd")})),this.innerAudioContext.onCanplay((e=>{this.$emit("audioCanplay")})),this.innerAudioContext.onPlay((()=>{this.$emit("change",{state:!0})})),this.innerAudioContext.onPause((()=>{this.$emit("change",{state:!1})}))},methods:{audioDestroy(){this.innerAudioContext&&(this.innerAudioContext.destroy(),this.audio_status=!1)},audioSeek(e){this.sliderChange(e)},audioPause(){this.clickAudio()},countDown(){Z=setInterval((()=>{this.sliderIndex=parseFloat(this.innerAudioContext.currentTime).toFixed(2),this.timeTxt=this.getTime(this.isCountDown?this.innerAudioContext.duration-this.innerAudioContext.currentTime:this.innerAudioContext.currentTime),this.timeTxt=this.isCountDown?"- "+this.timeTxt:this.timeTxt,this.innerAudioContext.currentTime>=this.innerAudioContext.duration&&clearInterval(Z)}),100)},clickAudio(){this.audio_status&&!this.innerAudioContext.paused?(this.innerAudioContext.pause(),clearInterval(Z)):this.innerAudioContext.play(),this.audio_status=!this.audio_status},getTime(e){let t=parseInt(e/60%60);t=t<10?"0"+t:t;let s=parseInt(e%60);return s=s<10?"0"+s:s,t+" : "+s},sliderChange(e){this.innerAudioContext.seek(e.detail?e.detail.value:e),this.sliderIndex=e.detail?e.detail.value:e}},onUnload(){this.audioDestroy()},onHide(){this.audioDestroy()},beforeDestroy(){this.audioDestroy()}},[["render",function(e,t,p,g,f,y){const x=u,_=m,C=h;return s(),i(_,{class:"audio_center"},{default:o((()=>[a(_,{class:"audio_center_cover"},{default:o((()=>[p.audioCover?(s(),i(x,{key:0,class:"audio_center_cover_img",mode:"aspectFill",src:p.audioCover},null,8,["src"])):n("",!0),a(_,{class:l(["iconfont",f.audio_status?"icon-play-stop":"icon-play-cell"]),onClick:y.clickAudio},null,8,["onClick","class"])])),_:1}),a(_,{class:"audio_center_right"},{default:o((()=>["string"==f.stringObject(p.src)?(s(),i(_,{key:0,class:"single"},{default:o((()=>[a(_,{class:"single_title"},{default:o((()=>[a(_,{class:"single_title_info",style:c({color:p.audioTitleColor})},{default:o((()=>[r(d(p.audioTitle),1)])),_:1},8,["style"]),a(_,{class:"tips"},{default:o((()=>[r(d(f.timeTxt),1)])),_:1})])),_:1}),a(_,{class:"tips"},{
|