How can I open or download mp3 files from view page
I want to be able to download or open the mp3 files in the infolist view page but if I remember there is no components for it
8 Replies
is there anyway to make the text a link to the file or make a section action to download the file
Infolists support actions. so you could just make an action to download the file. https://filamentphp.com/docs/3.x/infolists/actions
Create a custom view and use ViewEntry in your Infolist
ViewEntry::make('audio')
->viewData([
'audio' => $infolist->record->audio
])
->view('infolists.components.audio-view')
//in your infolists.components.audio-view.blade.php add this code
<audio controls>
<source src="{{$audio}}" type="audio/mpeg">
</audio>
I assume that audio in $infolist->record->audio is the name of the coloumn from my model so I replaced it with what my column is named
somehow it doesnt work tho
well theres a player but its grayed out
probably because its not getting the url
thanks for this, led me to check filesystems in laravel that let me download the file
Tho im still curious how to make the custom view work
If you say url is wrong then maybe check it?
which is why I was asking what $infolist->record->audio means
as ive tried changing the audio to my column name
nothing happened
changed it entirely an error showed up
so im confused as to if $infolist->record part points to the record that is showing up in the infolist
but if thats the case I couldve able to hit play on the custom view
as for the url, it is correct as I was able to make a download action
I don’t think ‘record’ is an attribute on $infolist. But in the view you should be able to use $getRecord() then call the attribute you need for the source off of that. Just remember that the attribute data might not be a full url so you might need to use the Storage facade to output the actual url to the file in the audio element’s src.
That makes more sense actually
Will look into this more