Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

Building Audio Player with Livewire v4

Create a custom audio player.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Component

Build an audio player component.

Component

blade
@persist('audio-player')
<div x-data="{ playing: false, progress: 0 }">
    <audio 
        x-ref="audio"
        @timeupdate="progress = ($refs.audio.currentTime / $refs.audio.duration) * 100">
        <source src="{{ $audioUrl }}" type="audio/mp3">
    </audio>
    
    <div class="progress" style="width: {{ progress }}%"></div>
    
    <button @click="$refs.audio.paused ? $refs.audio.play() : $refs.audio.pause()">
        Play/Pause
    </button>
</div>
@endpersist
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read