public function audio(string $audioFile, array $attributes = null) : self
    {
        if ($this->validate and ! $audioFile) {
            throw new Exception("Open Graph: Invalid audio URL (empty)");
        }

        if (strpos($audioFile, '://') === false and function_exists('asset')) {
            $audioFile = asset($audioFile);
        }

        if ($this->validate and ! filter_var($audioFile, FILTER_VALIDATE_URL)) {
            throw new Exception("Open Graph: Invalid audio URL '{$audioFile}'");
        }

        $this->tags[] = $this->createTag('audio', $audioFile);

        if ($attributes) {
            $valid = [
                'secure_url',
                'type',
            ];

            $tag = $this->lastTag('type');

            $specialValid = [];

            if ($tag and $tag->name == 'music.song') {
                $specialValid = [
                    'duration',
                    'album',
                    'album:disc',
                    'album:track',
                    'musician',
                ];
            }

            if ($tag and $tag->name == 'music.album') {
                $specialValid = [
                    'song',
                    'song:disc',
                    'song:track',
                    'musician',
                    'release_date',
                ];
            }

            if ($tag and $tag->name == 'music.playlist') {
                $specialValid = [
                    'song',
                    'song:disc',
                    'song:track',
                    'creator',
                ];
            }

            if ($tag and $tag->name == 'music.radio_station') {
                $specialValid = [
                    'creator',
                ];
            }

            $valid = array_merge($valid, $specialValid);

            $this->attributes('audio', $attributes, $valid);
        }

        return $this;
    }
public function audio(string $audioFile, array $attributes = null) : self
    {
        if ($this->validate and ! $audioFile) {
            throw new Exception("Open Graph: Invalid audio URL (empty)");
        }

        if (strpos($audioFile, '://') === false and function_exists('asset')) {
            $audioFile = asset($audioFile);
        }

        if ($this->validate and ! filter_var($audioFile, FILTER_VALIDATE_URL)) {
            throw new Exception("Open Graph: Invalid audio URL '{$audioFile}'");
        }

        $this->tags[] = $this->createTag('audio', $audioFile);

        if ($attributes) {
            $valid = [
                'secure_url',
                'type',
            ];

            $tag = $this->lastTag('type');

            $specialValid = [];

            if ($tag and $tag->name == 'music.song') {
                $specialValid = [
                    'duration',
                    'album',
                    'album:disc',
                    'album:track',
                    'musician',
                ];
            }

            if ($tag and $tag->name == 'music.album') {
                $specialValid = [
                    'song',
                    'song:disc',
                    'song:track',
                    'musician',
                    'release_date',
                ];
            }

            if ($tag and $tag->name == 'music.playlist') {
                $specialValid = [
                    'song',
                    'song:disc',
                    'song:track',
                    'creator',
                ];
            }

            if ($tag and $tag->name == 'music.radio_station') {
                $specialValid = [
                    'creator',
                ];
            }

            $valid = array_merge($valid, $specialValid);

            $this->attributes('audio', $attributes, $valid);
        }

        return $this;
    }
public function audio ( string $ audioFile , array $ attributes = null ) : self { if ( $ this -> validate and ! $ audioFile ) { throw new Exception ( "Open Graph: Invalid audio URL (empty)" ) ; } if ( strpos ( $ audioFile , '://' ) === false and function_exists ( 'asset' ) ) { $ audioFile = asset ( $ audioFile ) ; } if ( $ this -> validate and ! filter_var ( $ audioFile , FILTER_VALIDATE_URL ) ) { throw new Exception ( "Open Graph: Invalid audio URL '{$audioFile}'" ) ; } $ this -> tags [ ] = $ this -> createTag ( 'audio' , $ audioFile ) ; if ( $ attributes ) { $ valid = [ 'secure_url' , 'type' , ] ; $ tag = $ this -> lastTag ( 'type' ) ; $ specialValid = [ ] ; if ( $ tag and $ tag -> name == 'music.song' ) { $ specialValid = [ 'duration' , 'album' , 'album:disc' , 'album:track' , 'musician' , ] ; } if ( $ tag and $ tag -> name == 'music.album' ) { $ specialValid = [ 'song' , 'song:disc' , 'song:track' , 'musician' , 'release_date' , ] ; } if ( $ tag and $ tag -> name == 'music.playlist' ) { $ specialValid = [ 'song' , 'song:disc' , 'song:track' , 'creator' , ] ; } if ( $ tag and $ tag -> name == 'music.radio_station' ) { $ specialValid = [ 'creator' , ] ; } $ valid = array_merge ( $ valid , $ specialValid ) ; $ this -> attributes ( 'audio' , $ attributes , $ valid ) ; } return $ this ; }
Adds an audio tag.
If the URL is relative its converted to an absolute one.

@param  string     $audioFile  The URL of the video file
@param  array|null $attributes Array with additional attributes (pairs of name and value)
@return OpenGraph
Adds an audio tag . If the URL is relative its converted to an absolute one .