1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
| <template>
| <div class="mini-audio" v-if="path">
| <audio controls :src="path" class="aduioPlayer"></audio>
| </div>
| </template>
|
| <script>
| export default {
| name: "mini-audio",
| props: {
| path: {
| type: String,
| },
| currentTime: {
| type: Number,
| },
| },
| watch: {
| path: {
| handler(newVal) {
| if (newVal) {
| setImmediate(() => {
| this.play();
| }, 200);
| }
| },
| },
| },
| methods: {
| play() {
| const player = (this.container ? this.container : document).querySelector(
| ".aduioPlayer"
| );
| if (player) {
| player.currentTime = this.currentTime;
| player.play();
| }
| },
| getVideoPlayer() {
| let obj = null;
| const player = (this.container ? this.container : document).querySelector(
| ".aduioPlayer"
| );
| if (player) {
| obj = {
| currentTime: player.currentTime,
| paused: player.paused,
| };
| }
| return obj
| },
| },
| };
| </script>
|
| <style lang="less" scoped>
| .mini-audio {
| position: fixed;
| right: 40px;
| bottom: 100px;
| }
| </style>
|
|