Latest Register Log In

+ Advanced Search

Playing MP3 Audio Files

Playing MP3 Audio Files
By
02/16/17

For some websites, simply linking an MP3 file for download when it's uploaded to a listing isn't good enough -- you may want a built-in audio player in your listing details page. WSN Gallery handles this automatically, but for the other WSN scripts you'll need to make a modification.

To put the audio player in the attached files section of the details page, go to Admin Panel -> Listings -> Listing Fields and edit the "Attach Files" field. Find the "Custom Display HTML" section near the bottom, and add this at the top of that box:
<!-- BEGIN TOPLIST -->
<CONFIG>attachments,sortorder;time,50,ascending;ascending,type='link' AND objectid={LINKEFFECTIVEID} AND (filetitle LIKE '%.mp3'),,,0,0,0,0,0,0,,0</CONFIG>
<div class="audio"><audio controls="controls" src="{DIRURL}/download.php?attachid={ATTACHID}&id={ATTACHID}&action=stream" preload="none"></audio></div>
<!-- END TOPLIST -->


If you wish to forbid downloads and only allow listening via the player, find this section near the bottom:
<ul>
<!-- BEGIN LINK ATTACHMENTS -->
<IF not {ATTACHISIMAGE}>
<li><a href="{ATTACHDOWNLOADURL}" title="{ATTACHLABEL}">{ATTACHFILETITLE}</a> ({ATTACHKB} {LANG_GENERAL_KB}, {ATTACHDOWNLOADS} {LANG_DETAILS_DOWNLOADS})</li>
</IF>
<!-- END LINK ATTACHMENTS -->
</ul>
and replace it with
<ul>
<!-- BEGIN LINK ATTACHMENTS -->
<IF not {ATTACHISIMAGE}>
<IF {ATTACHEXTENSION} is not mp3>
<li><a href="{ATTACHDOWNLOADURL}" title="{ATTACHLABEL}">{ATTACHFILETITLE}</a> ({ATTACHKB} {LANG_GENERAL_KB}, {ATTACHDOWNLOADS} {LANG_DETAILS_DOWNLOADS})</li>
</IF>
</IF>
<!-- END LINK ATTACHMENTS -->
</ul>


That's it! You'll now automatically see an audio player on the details pages of listings that have mp3 files.




Rating
Views 482 views. Averaging 1 view per day.