PHP code example of ayacoo / ard-sounds

1. Go to this page and download the library: Download ayacoo/ard-sounds library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ayacoo / ard-sounds example snippets




namespace Vendor\ExtName\EventListener;

use Ayacoo\ArdSounds\Event\ModifyPodcastEpisodeEvent;

class PodcastEpisodeEventListener
{
    public function __invoke(ModifyPodcastEpisodeEvent $event): void
    {
        // Only step in if the built-in parsing found nothing, e.g. after a markup change
        if ($event->getEpisode() !== null) {
            return;
        }

        $episode = $this->parseYourOwnWay($event->getHtml());
        if ($episode !== null) {
            $event->setEpisode($episode);
        }
    }

    private function parseYourOwnWay(string $html): ?array
    {
        // ... your own extraction logic, must return an array with at least
        // the keys "name", "description" and "image", or null on failure
        return null;
    }
}



namespace Vendor\ExtName\EventListener;

use Ayacoo\ArdSounds\Event\ModifyArdSoundsOutputEvent;

class ArdSoundsOutputEventListener
{
    public function __invoke(ModifyArdSoundsOutputEvent $event): void
    {
        $output = $event->getOutput();
        $output = str_replace('src', 'data-src', $output);
        $event->setOutput($output);
    }
}