I’m new to Kirby and can’t figure out how to do this:
With my post, I’ll upload an audio file to the same folder. Using the audio tag (or a plugin), this file should be shown inside a player without specifying the file name or type (can be both .mp3 or .ogg).
I’ve tried using Kirbys own audio-tag and the audioext plugin, but both seem to use an URL instead of the local file and/or want me to write the file name and extension.
Jannik Beyerstedt’s kirbytag: download plugin works pretty much how I would like the audio player on my site to work. I don’t have to specify file name, file type or location and can just hardcode this into my template: (download: last type: audio text: Download). Any suggestions?
Thanks. I have no php experience, but finding the relevant code snippets from the download Plugin shouldn’t be that hard. I’ll try to figure it out when I get home. Just thought I missed some feature of the audio or audioext tags that would just work.
Well, I’m stuck
I’ve managed to extract the parts I need and ended up with this:
<?php
kirbytext::$tags[‘audiow’] = array(
$types = ‘audio’,
$files = $files->first);
?>
Problem is, I have no idea how to use it.
From what I understand, this filters the files in the same directory for types Kirby associates with audio and chooses the first file in there. So far, so good. But even if that code is correct (at least it doesn’t throw errors ;)), I don’t know how to make the player appear and use its resulting file.
I’ve been trying getting this to work using plyrtag, but I can’t figure out how to include the file path generated by the above php code to plyrtag. Hell, I’m not even sure this code does anything at all
Any help would be much appreciated.
Well, you have to define what you want to build and what you want to do with the different options. You can make it much simpler, if you don’t want to define anything and just fetch the first audio file no matter what: