123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <template>
- <div class="goeasy-audio-player" @click="playAudio">
- <div class="audio-facade" :style="{width:Math.ceil(duration)*7 + 50 + 'px'}">
- <div class="audio-facade-bg" :class="{'play-icon':play}"> </div>
- <div>{{Math.ceil(duration) || 1}}</div>
- </div>
- </div>
- </template>
- <script>
- const innerAudioContext = uni.createInnerAudioContext();
- export default {
- name: "GoEasyAudioPlayer",
- props: ['src', 'duration'],
- data() {
- return {
- play: false
- }
- },
- methods: {
- playAudio() {
- wx.setInnerAudioOption({
- obeyMuteSwitch: false
- })
- this.play = true;
- innerAudioContext.src = this.src;
- innerAudioContext.play();
- setTimeout(() => {
- this.play = false;
- }, this.duration * 1000)
- }
- }
- }
- </script>
- <style scoped>
- .goeasy-audio-player {
- margin-top: 12rpx;
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
- }
- .audio-facade {
- min-width: 20rpx;
- padding: 6rpx 10rpx;
- height: 72rpx;
- background: #618DFF;
- font-size: 24rpx;
- border-radius: 14rpx;
- color: #ffffff;
- display: flex;
- align-items: center;
- }
- .audio-facade-bg {
- background: url("./images/voice.png") no-repeat center;
- background-size: 30rpx;
- width: 40rpx;
- height: 100%;
- }
- .audio-facade-bg.play-icon {
- background: url("./images/play.gif") no-repeat center;
- background-size: 30rpx;
- -moz-transform: rotate(180deg);
- -webkit-transform: rotate(180deg);
- -o-transform: rotate(180deg);
- transform: rotate(180deg);
- }
- </style>
|