Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue-#20 #54

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.