CyberGene
I tried for many hours. So, I definitely tried... 😆 But, I keep getting errors when I try adding a template to the upload extension, through this extension.
But, I have one solution for you. You can replace your Flarum installation's main extend.php code with the following:
<?php
use Flarum\Extend;
use Flarum\Foundation\AbstractServiceProvider;
use FoF\Upload\Contracts\Template;
use FoF\Upload\File;
use FoF\Upload\Helpers\Util;
class AudioTemplate implements Template
{
public function tag(): string
{
return 'audio';
}
public function name(): string
{
return 'Audio template';
}
public function description(): string
{
return 'Audio template to use with Essential Audio';
}
public function preview(File $file): string
{
return '[play]' . $file->url . '[/play]';
}
}
class AudioServiceProvider extends AbstractServiceProvider
{
public function register()
{
$this->container->make(Util::class)->addRenderTemplate($this->container->make(AudioTemplate::class));
}
}
return [
(new Extend\ServiceProvider())
->register(AudioServiceProvider::class),
];
Now you can choose the audio template in the upload extension (with the right regular expression for audio files), and when an audio file is uploaded it will automatically have this Essential Audio extension's BBCode wrapped around the URL.
For some reason I can only get it to work this way right now. And, no download option.
At least you have some options now. Either do this, and/or use the updated Inline Audio player.