2

I don't know why setting audio current time is not working on google chrome while it's working fine on other browsers.

Here is my code.

<template>
<div>
    <audio ref="audioRef" src="audio.mp3"></audio>
    <div style="width: 280px !important">
        <div class="my-1 px-0 mx-0">
            <v-slider
                dense
                height="15"
                @change="moveAudio"
                hide-details
                :value="playerProgress"
            ></v-slider>
        </div>
    </div>
</div>
<script>
export default {
    data() {
        return {
            playerProgress: 0,
        };
    },

    methods() {
        playPauseAudio() {
            const audio = this.$refs.audioRef;         
            audio.paused ? audio.play(); : audio.pause();           
        },
        moveAudio(value) {
            const audio = this.$refs.audioRef;
            this.playerProgress = value;
            audio.currentTime = value; // This part cause audio to restart in google chrome while in other browsers it's going to that time.
        },
    }
}
</script>

Thanks in advance.

  • add more code snippet and details so it will be easy to help you out. – Anant Vikram Singh May 19 '22 at 11:28
  • restarts audio ? probably because `value` is negative or above duration of audio. – bogdanoff May 19 '22 at 11:57
  • No actually I have handled that part. No negative value or above duration is passed. It just restarts on chrome. It's working perfect on other browsers as I mentioned. – Rohullah Muhammadee May 19 '22 at 12:00
  • I can confirm exactly the same issue here :(. – zubozrout Jul 08 '22 at 15:13
  • And at least in my case it looks to be a "feature" related to how a file is served: https://stackoverflow.com/a/65804889/1642887 - which is sadly not a thing I can alter. – zubozrout Jul 11 '22 at 06:57
  • 1
    I recently figured out that it’s only not working due to CORS policy. In my case I was accessing audio from ‘http://localhost:3000’ while my server was on ‘http://localhost:8000’ and bcoz both are http not https it was causing that problem. Its was fixed automatically when I host my project on live server. – Rohullah Muhammadee Jul 21 '22 at 04:15
  • Does this answer your question? [Can't set currentTime in Chrome](https://stackoverflow.com/questions/45293767/cant-set-currenttime-in-chrome) – Tsunamis Sep 16 '22 at 15:31

0 Answers0