F
Filament7mo ago
Gudao

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
No description
8 Replies
Gudao
GudaoOP7mo ago
is there anyway to make the text a link to the file or make a section action to download the file
awcodes
awcodes7mo ago
Infolists support actions. so you could just make an action to download the file. https://filamentphp.com/docs/3.x/infolists/actions
akfred
akfred7mo ago
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>
Gudao
GudaoOP7mo ago
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
krekas
krekas7mo ago
If you say url is wrong then maybe check it?
Gudao
GudaoOP7mo ago
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
awcodes
awcodes7mo ago
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.
Gudao
GudaoOP7mo ago
That makes more sense actually Will look into this more
Want results from more Discord servers?
Add your server