Skip to content

Commit

Permalink
fix: Listen audio not play
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jun 23, 2022
1 parent 5019cf8 commit a174f3e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/components/AudioComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ import {useStore} from '../stores/dataStore'
},
methods: {
setAudio(){
this.audio = new Audio(this.$refs.audioPlayer.dataset.url);
this.audio = new Audio('');
},
async checkIsDownloaded() {
if (this.$refs.audioPlayer.dataset.url === undefined) {
if (this.audio.src.includes('/chat')) {
await api.get(`${getSession()}/get-media-by-message/${this.message.id}`,configHeader())
.then((result)=>{
this.$emit('setUrl', result.data.base64)
this.audio = new Audio(this.$refs.audioPlayer.dataset.url);
this.start()
this.audio = new Audio('data:audio/ogg;base64,'+result.data.base64);
setTimeout(()=> {
this.start()
},200)
})
} else {
this.start();
Expand Down Expand Up @@ -100,9 +101,6 @@ import {useStore} from '../stores/dataStore'
},
formatTimeToDisplay(seconds) {
var milliseconds = seconds * 1000;
/*if(!Number.isInteger(seconds) ){
milliseconds = 1 * 1000;
}*/
return new Date(milliseconds).toISOString().substr(14, 5);
},
Expand Down

0 comments on commit a174f3e

Please sign in to comment.