1
1
<template >
2
2
<v-list-item :ripple =" false" >
3
+ <div class =" mr-5" >
4
+ <span class =" overline mr-1" >Recording {{ recording.number }}</span >
5
+ </div >
3
6
<v-list-item-avatar >
4
7
<v-btn x-large icon @click =" toggleAudio" >
5
8
<v-icon v-if =" isPlaying" >mdi-pause</v-icon >
6
9
<v-icon v-else >mdi-play</v-icon >
7
10
</v-btn >
8
11
</v-list-item-avatar >
9
- <v-list-item-content >
10
- <v-list-item-title class =" overline" >
11
- Recording {{ index + 1 }}
12
- </v-list-item-title >
12
+ <v-list-item-content class =" px-5" >
13
13
<v-slider
14
- :value =" progress"
15
14
active
16
15
color =" primary lighten-4"
17
16
rounded
18
- inverse-label
19
- :label = " `${elapsedTime} / ${totalTime}` "
17
+ :value = " progress "
18
+ :hide-details = " true "
20
19
@change =" seek"
21
20
@start =" sliderConnected = false"
22
21
@end =" sliderConnected = true"
23
22
/>
24
23
</v-list-item-content >
24
+ <div class =" caption mr-5 ml-3 " >
25
+ <span > {{ elapsedTime }} / {{ totalDuration }} </span >
26
+ </div >
25
27
<v-list-item-action >
26
- <v-btn icon x-small color =" primary darken-3" >
28
+ <v-btn
29
+ icon
30
+ x-small
31
+ color =" primary darken-3"
32
+ :href =" href"
33
+ :download =" download"
34
+ >
27
35
<v-icon >mdi-download</v-icon >
28
36
</v-btn >
29
37
</v-list-item-action >
30
38
<v-list-item-action >
31
- <v-btn icon x-small >
39
+ <v-btn
40
+ icon
41
+ x-small
42
+ color =" primary lighten-3"
43
+ @click =" $emit('remove-item', recording.id)"
44
+ >
32
45
<v-icon >mdi-close</v-icon >
33
46
</v-btn >
34
47
</v-list-item-action >
35
48
</v-list-item >
36
49
</template >
37
50
<script >
38
- function getMMSS (duration ) {
39
- let minutes = Math .floor (duration / 60 )
40
- let seconds = parseInt (duration , 10 ) - minutes * 60
51
+ function getMMSS (timeInSeconds ) {
52
+ let minutes = Math .floor (timeInSeconds / 60 )
53
+ let seconds = parseInt (timeInSeconds , 10 ) - minutes * 60
41
54
42
55
if (minutes < 10 ) {
43
56
minutes = ' 0' + minutes
@@ -55,12 +68,8 @@ export default {
55
68
type: Object ,
56
69
default : () => ({
57
70
audio: null ,
58
- isPlaying : false
71
+ encoding : ' mp3 '
59
72
})
60
- },
61
- index: {
62
- type: Number ,
63
- default: 0
64
73
}
65
74
},
66
75
data () {
@@ -70,21 +79,23 @@ export default {
70
79
totalDuration: null ,
71
80
elapsedTime: ` 00:00` ,
72
81
progress: 0 ,
73
- sliderConnected: true
74
- }
75
- },
76
- computed: {
77
- totalTime () {
78
- return getMMSS (this .totalDuration )
82
+ sliderConnected: true ,
83
+ href: null ,
84
+ download: ' '
79
85
}
80
86
},
81
87
beforeMount () {
82
88
this .track = new Audio (this .recording .audio )
83
89
90
+ this .href = this .recording .audio
91
+ this .download = ` Recording ${ this .recording .number + 1 } .${
92
+ this .recording .encoding
93
+ } `
94
+
84
95
this .track .addEventListener (' loadeddata' , () => {
85
96
console .log (' finished loading' )
86
97
console .log (this .track .duration )
87
- this .totalDuration = this .track .duration
98
+ this .totalDuration = getMMSS ( this .track .duration )
88
99
})
89
100
90
101
this .track .addEventListener (' ended' , () => {
@@ -93,7 +104,7 @@ export default {
93
104
})
94
105
95
106
this .track .addEventListener (' timeupdate' , (event ) => {
96
- const s = parseInt (this .track .currentTime % 60 )
107
+ const s = parseInt (this .track .currentTime , 10 )
97
108
this .elapsedTime = getMMSS (s)
98
109
99
110
if (this .sliderConnected ) {
@@ -112,8 +123,6 @@ export default {
112
123
},
113
124
seek (payload ) {
114
125
if (typeof payload === ' number' ) {
115
- console .log (' endseeking' , payload)
116
- console .log ((payload * this .track .duration ) / 100 )
117
126
this .track .currentTime = (payload * this .track .duration ) / 100
118
127
}
119
128
}
0 commit comments