Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
¿Qué función se puede usar para seguir reproduciendo audio después de que finalice el actual?

Estoy tratando de reproducir la siguiente canción en una lista de reproducción/álbum después de que la actual haya terminado de reproducirse. Pude reproducir una canción, pero no pasa a la siguiente después de que la actual termina de reproducirse.

Aquí está mi código:

 <button class="controlButton play" title="Play" @click="play" v-if="!isPlaying"> <img src="storage/icons/play.png" alt="Play"> </button> <button class="controlButton pause" title="Pause" @click="pause" v-else> <img src="storage/icons/pause.png" alt="Pause"> </button>
 <script> import { Link } from "@inertiajs/inertia-vue3"; export default { components: { Link }, data() { return { audio: new Audio(), currentSong: {}, myWidth: 0, loop:{}, index: 0, songs: [ { title: 'Song', artist: 'Artis A', src: '/storage/audio/song.mp3', cover: '/storage/images/cover.jpeg', }, { title: 'Song 2', artist: 'Artis B', src: '/storage/audio/song2.mp3', cover: '/storage/images/cover2.jpeg', }, mounted() { this.currentSong = this.songs[this.index]; }, methods: { play(song) { if(typeof song.src != 'undefined') { this.currentSong = song; this.audio.src = this.currentSong.src } this.audio.play(); this.isPlaying = true this.activeItem = this.currentSong }, pause() { this.audio.pause(); this.isPlaying = false; }, }

¿Cómo puedo hacer que la segunda canción se reproduzca después de que la actual haya terminado y también cambiar el botón para volver a reproducir cuando no quede ninguna canción?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El objeto Audio (que es un HTMLAudioElement, que hereda de HTMLMediaElement) expone un evento ended , que puede escuchar.

 mounted() { this.audio.addEventListener('ended', (event) => { // go to next song }) }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!