Skip to content

Commit

Permalink
Merge pull request #54 from dacoaster/issue-20
Browse files Browse the repository at this point in the history
fix issue-#20
  • Loading branch information
dacoaster authored Jun 28, 2023
2 parents 2ec175d + b2eec70 commit b8938cc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 102 deletions.
47 changes: 34 additions & 13 deletions src/components/AudioWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@
<div ref="waveform" class="mb-2 waveform"></div>
<v-row>
<v-col cols="12" class="progress-bar">
<span class="time">00:00</span>
<span class="time" :style="{ color: currentTheme.secondary }"
>00:00</span
>
<div class="progress">
<v-slider
v-model="currentProgress"
max="100"
min="0"
color="primary"
step="1"
thumb-label
:thumb-size="20"
hide-details
hide-spin-buttons
track-color="#D1D5DB"
@change="syncSlideWithAudio"
></v-slider>
</div>
<span class="time">{{ durationTime }}</span>
<!-- move prop from controlPanel and get colors from Vuetify.js -->
<span class="time" :style="{ color: currentTheme.secondary }">{{
durationTime
}}</span>
</v-col>
</v-row>
<v-row class="d-flex justify-space-between">
Expand Down Expand Up @@ -114,6 +123,7 @@ export default {
data: () => ({
wavesurfer: null,
volume: 20,
currentProgress: 0,
}),
watch: {
triggerSave: function (oldValue, newValue) {
Expand All @@ -123,6 +133,13 @@ export default {
},
},
computed: {
currentTheme() {
if (this.$vuetify.theme.dark) {
return this.$vuetify.theme.themes.dark;
} else {
return this.$vuetify.theme.themes.light;
}
},
isPlaying() {
if (!this.wavesurfer) return false;
Expand All @@ -141,22 +158,11 @@ export default {
duration = parseFloat(this.wavesurfer.getDuration()).toFixed(2);
}
duration = 0;
const date = new Date(null);
date.setSeconds(duration);
const result = date.toISOString().substr(14, 5);
return result;
},
currentTime() {
if (!this.wavesurfer) return 0;
// return this.wavesurfer.getCurrentTime();
const duration = parseInt(this.wavesurfer.getDuration());
const current = parseInt(this.wavesurfer.getCurrentTime());
const result = Math.round((current / duration) * 100);
return result;
},
},
mounted() {
if (!this.wavesurfer) {
Expand All @@ -176,6 +182,21 @@ export default {
barWidth: 3,
});
this.wavesurfer.load(`file://${this.item.filePath}`);
this.wavesurfer.on("audioprocess", () => {
this.setCurrentProgress();
});
},
setCurrentProgress() {
if (!this.wavesurfer) return 0;
// return this.wavesurfer.getCurrentTime();
const duration = parseFloat(this.wavesurfer.getDuration());
const current = parseFloat(this.wavesurfer.getCurrentTime());
const result = Math.round((current / duration) * 100);
this.currentProgress = result;
},
syncSlideWithAudio() {
this.wavesurfer.seekTo(this.currentProgress / 100);
},
setVolume() {
const volume = Math.round(this.volume);
Expand Down
89 changes: 0 additions & 89 deletions src/components/dialogs/AudioRecordingDialog.vue

This file was deleted.

0 comments on commit b8938cc

Please sign in to comment.