From 98b49c470e0130efb09e07e2f57ac98035b583fb Mon Sep 17 00:00:00 2001 From: douzhuo <17611323298@163.com> Date: Tue, 22 Mar 2022 19:51:24 +0800 Subject: [PATCH] init test --- components/yz-audio/audioBg.js | 87 +++++ components/yz-audio/index.scss | 119 +++++++ components/yz-audio/static/backimg.png | Bin 0 -> 594 bytes components/yz-audio/static/bg.png | Bin 0 -> 1871 bytes components/yz-audio/static/bg_act.png | Bin 0 -> 1994 bytes components/yz-audio/static/loading.png | Bin 0 -> 331 bytes components/yz-audio/static/loading2.png | Bin 0 -> 333 bytes components/yz-audio/static/pausebtn.png | Bin 0 -> 189 bytes components/yz-audio/static/playbtn.png | Bin 0 -> 274 bytes components/yz-audio/yz-audio.vue | 432 ++++++++++++++++++++++++ store/index.js | 54 +++ 11 files changed, 692 insertions(+) create mode 100644 components/yz-audio/audioBg.js create mode 100644 components/yz-audio/index.scss create mode 100644 components/yz-audio/static/backimg.png create mode 100644 components/yz-audio/static/bg.png create mode 100644 components/yz-audio/static/bg_act.png create mode 100644 components/yz-audio/static/loading.png create mode 100644 components/yz-audio/static/loading2.png create mode 100644 components/yz-audio/static/pausebtn.png create mode 100644 components/yz-audio/static/playbtn.png create mode 100644 components/yz-audio/yz-audio.vue create mode 100644 store/index.js diff --git a/components/yz-audio/audioBg.js b/components/yz-audio/audioBg.js new file mode 100644 index 0000000..e9507fd --- /dev/null +++ b/components/yz-audio/audioBg.js @@ -0,0 +1,87 @@ +import { + mapState, + mapActions, + mapMutations +} from 'vuex' +export const audios = { + data() { + return { + isBgPlay: false, // 是否禁止拖拽进度条 + } + }, + + computed: { + ...mapState(['bgAudioMannager']), + }, + + methods: { + setAudio(obj) { + this.bgAudioMannager.title = '录音音频'; + this.bgAudioMannager.src = obj.src + this.bgAudioMannager.startTime = obj.currentTime + }, + + setAudioFunc() { + this.bgAudioMannager.onCanplay(() => { + console.log('可以播放'); + }); + this.bgAudioMannager.onStop(() => { + console.log('停止播放'); + this.isBgPlay = false + }); + + this.bgAudioMannager.onPause(() => { + console.log('暂停播放'); + this.isBgPlay = false + // 设置当前暂停的视频播放位置 + // this.seek(this.bgAudioMannager.currentTime) + // this.play() + }); + + this.bgAudioMannager.onEnded(() => { + console.log('自然播放结束事件'); + this.isBgPlay = false + }); + + this.bgAudioMannager.onError((res) => { + console.log(res.errMsg); + console.log(res.errCode); + }); + + this.bgAudioMannager.onTimeUpdate(() => { + this.isBgPlay = true + this.duration = this.bgAudioMannager.duration; + this.currentTime = this.bgAudioMannager.currentTime; + this.$emit('timeUpdate', { + duration: this.bgAudioMannager.duration, + currentTime: this.bgAudioMannager.currentTime + }) + }); + }, + + // 背景音频暂停 + audioPause() { + this.bgAudioMannager.pause() + }, + + // 背景音频播放 + audioPlay() { + this.pause() + this.bgAudioMannager.play() + }, + + //背景音频指定秒数播放 + audioSeek(t) { + this.bgAudioMannager.seek(t) + }, + + // 停止背景音频播放 + stopAduio() { + console.log(this.bgAudioMannager) + this.bgAudioMannager.pause() + if (this.bgAudioMannager && this.bgAudioMannager.src) { + this.bgAudioMannager.src = '' + } + } + } +} diff --git a/components/yz-audio/index.scss b/components/yz-audio/index.scss new file mode 100644 index 0000000..53c375b --- /dev/null +++ b/components/yz-audio/index.scss @@ -0,0 +1,119 @@ +@mixin textoverflow() { + display: -webkit-box; + overflow: hidden; + text-overflow: ellipsis; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; +} +@keyframes rowup { + 0% { + -webkit-transform: translate(-50%, -50%) rotate(0deg); + transform-origin: center center; + } + + 100% { + -webkit-transform: translate(-50%, -50%) rotate(360deg); + transform-origin: center center; + } +} +.imt-audio{ + position:relative; + width: 100%; + display: flex; + box-sizing: border-box; + background: #fff; + overflow: hidden; + + .top { + width: 140rpx; + position: relative; + } + + .audio-wrapper { + display: flex; + flex-direction: column; + flex: 1; + color: #fff; + margin-left: 20rpx; + } + .slidebox { + display: flex; + justify-content: space-between; + width: 96%; + } + /deep/ .uni-slider-tap-area { + padding: 0; + } + /deep/ .uni-slider-wrapper { + min-height: 0; + } + /deep/ .uni-slider-handle-wrapper { + height: 6px; + } + .audio-slider { + padding-top: 10rpx; + margin-left: 150rpx; + position: absolute; + bottom: 40rpx; + width: 75vw; + left: 0; + padding: 0; + } + + + // .cover { + // width: 120rpx; + // height: 120rpx; + // box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2); + // position: absolute; + // top: 50%; + // left: 50%; + // transform: translate(-50%, -50%); + // animation-fill-mode: forwards; + // -webkit-animation-fill-mode: forwards; + // } + + .play { + width: 48rpx; + height: 48rpx; + z-index: 99; + background: rgba(0, 0, 0, 0.4); + border-radius: 50%; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + &.loading{ + width: 48rpx; + height: 48rpx; + animation: rotating_theme3 2s linear infinite; + } + } +} + +@keyframes rotating { + 0% { + transform: rotateZ(0deg) + } + 100% { + transform: rotateZ(360deg) + } +} +@keyframes rotating_theme3 { + 0% { + transform: translate(-50%, -50%) rotateZ(0deg) + } + 100% { + transform: translate(-50%, -50%) rotateZ(360deg) + } +} + +.hItem +{ + margin-left: 16rpx; +} + +.extrButton +{ + font-size: 36rpx; +} \ No newline at end of file diff --git a/components/yz-audio/static/backimg.png b/components/yz-audio/static/backimg.png new file mode 100644 index 0000000000000000000000000000000000000000..fef382f116185b30f28f34dc2e04629f68bbf7d1 GIT binary patch literal 594 zcmV-Y0Px%3`s;mR9Hvtmp_OTK@`T{mkn4bihl@*Rza=Q!Z*nlf^daGU<J+NgfuF%>X`-d@3T-&bhDa^(&6!LZi_*Lvj+pzAPWfcK{ZmD0&db zad*8nRCSw(Tmo>M5QR_Fg?Kp2Kw(=@$J^5Wkb0PsGGIp>~?+h7=m z`_nX?C3$p6jm01crjjIiJ8lhCJpo{bhaSBxl}e>*v)TOFGeA{uipX^j zp#WGWdC)oc(TC5N{|znkODZ68E~cB?cVVf_PH<4xgEY5 zRb3E~lfHbPd+eN>^wp^9@(8QnOIs)uuEH2|m*i#NLMvPl1iMk07*qoM6N<$f}^t&A^-pY literal 0 HcmV?d00001 diff --git a/components/yz-audio/static/bg.png b/components/yz-audio/static/bg.png new file mode 100644 index 0000000000000000000000000000000000000000..b49474e16c4d52b439cc02f79a2c9d148863391b GIT binary patch literal 1871 zcmV-V2e9~wP)Px+2}wjjRCr$PTWf4oRS=#z-7XYeB}FkBj8+UH7=fH~x3-YDB4RW&K0-~zM+DSB zASU_)R5aGN#vlCf1pyH>_yB`SpwXhqsx5W*o=XKuK>blrAgDYH1?>uZ$4s+J?k;y9 zx7~$Z-1Dc+-Z?X8zI$fQ%(*iNE~B}*xvIOndm0hl0RZ)gcnJ}m=SDlg-~I-GeTcXX z06wd&tzFmF)^==wJUvavbZRN(Q~+2E0AoCHDh%;H0C>`}tW||!mzzrp0ES^aVcYhL z0B{O0xmgvIVtF7Cm>Uj2xWd zloJdFN7=T$m52sAK$x$!ezRC>VF2DBqInL1E40?LizP4@U!~LnB6`)ao=sY7KADO# zP)fNK0Ip4P_xXI|B9RE6%V%UvoH#Mi+uM5p0Q|fFMC{dC*A#0p3;^5v1*bz;zDh_b ze*l1SNqWEEKdiH}^H9F?z0ffLw&UF2YgyI^FAR!7E2ZQUX>yWxRaMnh(P;GNV#s0u z$YF1LwAPmvLy#AqN~ujmG{v#5(OT=Dyzt1Ewp0Q5iimFPF96NW&Hi1xc8wvT(L^*9 z5f2CG(H}Wk4MA_0Km%DdC6T6F^-5cOw(Lb$^fLBK$M8CNS;>t+IJ>8MC2rEy4L#h zQr!V501QCkKLDTy04@fAAx=Jsc%-_zy6$WOU>728A)+n-=o&nDa92l12j4G1BI)8( z|EV+(7L^?UY{LMsla)*=8wdot!r|~=xpsOCU5&q4QnSpa~D9}>~GthC?n-`3gL z`A;ro-JS=7!O8J>oP(_7h?NTf1qpVO+YgM)rqf}3UjOlPoON(f2ZM~8e@ z{IJp-?Rg%h3P8FEJWE6uasos|e0_J0XH7FqC<_1vs4R!b8URd0++o}H`m*x@9st;z zP*e*cSZN)NMh_zP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^!jDKe&(spl7XH`JCyw9?C0`i5T zO~A6ZXh;$$0xvQ%nJA=TVxwg*IYE8~km7D+$wMDs+WON_h&m?#1vE^UU1PV1qkmqm z6Qtq}uIU=T-f^6?_L!<_nE~z^iM0JN6)?A{LT0ANQkywhLKtLY!&Ql{G1D6D6X448 zLaL)_ip1gOmWC_#hgP4?Trp;F^ga=Mqtrx*#M9Am+egl|%~|$)HLzz+ru084SPR7pQByV8GD=7@#h7& ztWbxX*cJnuha=uUx^t?tbryKAW21NLFK%(mV&{L{+MqLf=1CEGUp`ub|A2v;Q=7u( zHcxks-k>!i0M_JVxX|Nn^EAlrLSlNRY=5VHlL)>ff@|iQG7k`Vq}lZRX#W>Eli@e! zs*yNon6x)j^Cl2iRjz#=GeWv{co4)do0l5D%I5Hj0eY=vU!+N&23HyePc%>;8r<%2 cBSzNeKl(RKC8h|DO8@`>07*qoM6N<$f`oOY)&Kwi literal 0 HcmV?d00001 diff --git a/components/yz-audio/static/loading.png b/components/yz-audio/static/loading.png new file mode 100644 index 0000000000000000000000000000000000000000..edd7142de8e5472375f74c11270c4d4c9e96be4a GIT binary patch literal 331 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDB3?!H8JlO)I)B}7%T!Hj|BEULZFH4|Oo{}KH zV1|Y(`&TM2p4#6rcXq9VHy=>^xTlL_h{fsT1-uDC2NV^HCrlG!JR!7(qi|mH2_Yl) z2SSGFY6>bA=Ve;G4dz)kPIzId++dJ>ZYI+VmftfcdrT{yW63%>qIenO%}CR9Aqj~Y zyb=;O&dInJ>R+F!EYNm-ChH2jla|a2&&xP}R^q;L-H4B;gtbYbq4jhP8w-zvPl%rI z3|3Ee4n4ocFSsHW9Mn@j(4c(d;w3S2r9}&(1OmA|-{!1{vN$)VO|{L|KzGJTb`K$s sf*GDu92Olr!&Y*-nS;UatqCJToOf8HUY^M=pqCgtUHx3vIVCg!0LPw(3;+NC literal 0 HcmV?d00001 diff --git a/components/yz-audio/static/loading2.png b/components/yz-audio/static/loading2.png new file mode 100644 index 0000000000000000000000000000000000000000..3483c9de5dde14271aa5948da74280a9f635783b GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDB3?!H8JlO)I)B}7%T!HlT>C%Knx0%8Tbr?eAdzlaT`yKk4b>7-Dfcc>!-i&;doo;tA7)I8O-W za1_p4d_u^O{eh5Wx|xE?j`K3j-W%pwwoZsBR%1xKHqTf%L1<38pK|26(q}9_i=Llh zN=ZL!8GPWtfgB*Nd#2J=ZFx?n(V*s>$%0=?p7FHU70aCM)(MC|ZDDXhl%t73Oz*R# zfB}PH;7*?eF%?;b9TvTdv=bWHcK0wa_a)e$XwY8tAW9(c^b&@yTZ?&i2stw_e|yrr zrd3e)prGF(8}^C9ThB1Y+-%6J6kt5Ca;_Q!!|X2+uei6*y94wTgQu&X%Q~loCIFeI Bfx`d* literal 0 HcmV?d00001 diff --git a/components/yz-audio/static/pausebtn.png b/components/yz-audio/static/pausebtn.png new file mode 100644 index 0000000000000000000000000000000000000000..f2bc86cf1406f07591eb276552cb2a509bf17d79 GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^O+Z}D#0(^le%P=dNbv;tgt!9f|NsC0{qyhrtFMkh z+BrZzV@Z%-FoVOh8)-mJyr+v}NW|e}3D(64B0Wuk4q6v_7$*88@>+z(@Y*t{_&ReJ zXeRLSmNEn_Txhr>#GtKBjbY`=g^Cp+EDdKQLJe0Xg&bYcmAIBEN^Da6Jf%}9N~gXC i8gRKC)R16RVPZIcBJ#r)Up}Bs3=E#GelF{r5}E*?rah4W literal 0 HcmV?d00001 diff --git a/components/yz-audio/static/playbtn.png b/components/yz-audio/static/playbtn.png new file mode 100644 index 0000000000000000000000000000000000000000..3f51b61d3cd72bf3fb5a918138e1261ccdafe038 GIT binary patch literal 274 zcmeAS@N?(olHy`uVBq!ia0vp^O(4v|3?wUbdCvhU=>VS)S0MfW|NobdKK}jl@8^%- zUqAkM^Yqh)*I(bi{9@vpI1wn#SQ6wH%;50sMjDW_)YHW=B;(%OYa0cb40&8GN(*_2 z_seomEl^#-;0#fAmFtrJ5o@MvYQiiSj7XvM-=vEjoXriHisi&B2~uKG6Jbn)Nzoww?5iB>$? z;=lK<-QVyBx+`jh58r<9+u?30+x;_hLH5o0-EJqdU02WATx15&!3>_RelF{r5}E)$ CYj?l^ literal 0 HcmV?d00001 diff --git a/components/yz-audio/yz-audio.vue b/components/yz-audio/yz-audio.vue new file mode 100644 index 0000000..c246769 --- /dev/null +++ b/components/yz-audio/yz-audio.vue @@ -0,0 +1,432 @@ + + + + + diff --git a/store/index.js b/store/index.js new file mode 100644 index 0000000..ee53307 --- /dev/null +++ b/store/index.js @@ -0,0 +1,54 @@ +import Vue from 'vue'; +import Vuex from 'vuex'; + +Vue.use(Vuex) + +export default new Vuex.Store({ + state: { + bgAudioMannager: null, + }, + + mutations: { + createAudio(state) { + state.bgAudioMannager = uni.getBackgroundAudioManager(); + }, + + setSeekAudio(state, t) { + state.bgAudioMannager.seek(t) + }, + + // 加载音频监听方法 + initAudioMethod (state, obj) { + state.bgAudioMannager.onCanplay(() => { + state.bgAudioMannager.currentTime = obj.currentTime + }); + state.bgAudioMannager.onStop(() => { + console.log('停止播放'); + }); + + state.bgAudioMannager.onPause(() => { + console.log('暂停播放'); + }); + state.bgAudioMannager.onEnded(() => { + //初始化 需要的参数 + console.log('自然播放结束事件'); + }); + state.bgAudioMannager.onError((res) => { + console.log(res.errMsg); + console.log(res.errCode); + }); + }, + + // 停止全局音频播放 + stopAduio(state) { + state.bgAudioMannager && state.bgAudioMannager.pause() + if (state.bgAudioMannager && state.bgAudioMannager.src) { + state.bgAudioMannager.src = '' + } + }, + }, + + action: { + + } +}) \ No newline at end of file