Apple News API PHP Client

Audio extends Component
in package

FinalYes

Audio component for audio content playback.

The audio component embeds an audio player for podcast episodes, music clips, or other audio content.

Tags
see
https://developer.apple.com/documentation/apple_news/audio

Table of Contents

Properties

$anchor  : string|null
$animation  : array<string, mixed>|null
$behavior  : array<string, mixed>|null
$conditional  : array<string, mixed>|null
$hidden  : bool
$identifier  : string|null
$layout  : string|null
$style  : string|null
$accessibilityCaption  : string|null
The accessibility caption for VoiceOver users.
$caption  : string|null
The caption for the audio.
$explicitContent  : bool|null
Whether the audio contains explicit content.
$imageURL  : string|null
URL to an image to display while audio is loading or paused.
$url  : string

Methods

__construct()  : mixed
Create a new Audio component.
fromBundle()  : self
Create an Audio from a bundle file reference.
fromUrl()  : self
Create an Audio from a URL.
getRole()  : string
Get the role name for the component (e.g., 'body', 'photo', 'heading1').
getStyle()  : string|null
Get the component style name.
jsonSerialize()  : array<string, mixed>
Implementation of JsonSerializable.
setAccessibilityCaption()  : $this
Set the accessibility caption for VoiceOver.
setAnchor()  : static
Set the anchor configuration.
setAnimation()  : static
Set component animation using an array.
setAnimationObject()  : static
Set the component animation using a typed Animation object.
setBehavior()  : static
Set the component behavior using an array.
setBehaviorObject()  : static
Set the component behavior using a typed Behavior object.
setCaption()  : $this
Set the audio caption.
setConditional()  : static
Set conditional properties for the component.
setExplicitContent()  : $this
Set whether the audio contains explicit content.
setHidden()  : static
Set whether the component is hidden.
setIdentifier()  : static
Set a unique identifier for this component.
setImageURL()  : $this
Set the image URL to display while audio loads or is paused.
setLayout()  : static
Set the layout name or inline layout.
setStyle()  : static
Set the style name.
getBaseProperties()  : array<string, mixed>
Get the base properties common to all components for JSON serialization.

Properties

$anchor

protected string|null $anchor = null

Anchor configuration for pinning components.

$animation

protected array<string, mixed>|null $animation = null

Animation settings for the component.

$behavior

protected array<string, mixed>|null $behavior = null

Behavior settings (e.g., Parallax).

$conditional

protected array<string, mixed>|null $conditional = null

Conditional properties based on orientation/device.

$hidden

protected bool $hidden = false

Whether the component is hidden by default.

$identifier

protected string|null $identifier = null

A unique identifier for this component instance.

$layout

protected string|null $layout = null

Reference to a named layout defined in Article.

$style

protected string|null $style = null

Reference to a named style defined in Article.

$accessibilityCaption

The accessibility caption for VoiceOver users.

private string|null $accessibilityCaption = null

$caption

The caption for the audio.

private string|null $caption = null

$explicitContent

Whether the audio contains explicit content.

private bool|null $explicitContent = null

$imageURL

URL to an image to display while audio is loading or paused.

private string|null $imageURL = null

$url read-only

private string $url

Methods

__construct()

Create a new Audio component.

public __construct(string $url) : mixed
Parameters
$url : string

The URL to the audio file (MP3, AAC, etc.).

fromBundle()

Create an Audio from a bundle file reference.

public static fromBundle(string $filename) : self
Parameters
$filename : string

The filename in the article bundle.

Return values
self —

A new Audio instance.

fromUrl()

Create an Audio from a URL.

public static fromUrl(string $url) : self
Parameters
$url : string

The audio file URL.

Return values
self —

A new Audio instance.

getRole()

Get the role name for the component (e.g., 'body', 'photo', 'heading1').

public getRole() : string
Return values
string

getStyle()

Get the component style name.

public getStyle() : string|null
Return values
string|null —

The name set with setStyle(), or null.

jsonSerialize()

Implementation of JsonSerializable.

public jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>

setAccessibilityCaption()

Set the accessibility caption for VoiceOver.

public setAccessibilityCaption(string $caption) : $this
Parameters
$caption : string

The accessibility caption.

Return values
$this

setAnchor()

Set the anchor configuration.

public setAnchor(string $anchor) : static
Parameters
$anchor : string

The anchor configuration.

Return values
static

setAnimationObject()

Set the component animation using a typed Animation object.

public setAnimationObject(AnimationInterface $animation) : static

This method provides type-safe animation configuration:

$photo->setAnimationObject(FadeInAnimation::fromTransparent());
$body->setAnimationObject(MoveInAnimation::fromLeft());
Parameters
$animation : AnimationInterface

The animation object.

Return values
static

setBehaviorObject()

Set the component behavior using a typed Behavior object.

public setBehaviorObject(BehaviorInterface $behavior) : static

This method provides type-safe behavior configuration:

$photo->setBehaviorObject(Parallax::withFactor(0.8));
$photo->setBehaviorObject(new Springy());
Parameters
$behavior : BehaviorInterface

The behavior object.

Return values
static

setCaption()

Set the audio caption.

public setCaption(string $caption) : $this
Parameters
$caption : string

The caption text.

Return values
$this

setExplicitContent()

Set whether the audio contains explicit content.

public setExplicitContent(bool $explicit) : $this
Parameters
$explicit : bool

Whether the content is explicit.

Return values
$this

setHidden()

Set whether the component is hidden.

public setHidden(bool $hidden) : static
Parameters
$hidden : bool

Whether to hide the component.

Return values
static

setIdentifier()

Set a unique identifier for this component.

public setIdentifier(string $identifier) : static
Parameters
$identifier : string

The unique identifier.

Return values
static

setImageURL()

Set the image URL to display while audio loads or is paused.

public setImageURL(string $imageURL) : $this
Parameters
$imageURL : string

The image URL.

Return values
$this

setLayout()

Set the layout name or inline layout.

public setLayout(string $layout) : static
Parameters
$layout : string

Reference to a name in componentLayouts.

Return values
static

setStyle()

Set the style name.

public setStyle(string $style) : static
Parameters
$style : string

Reference to a name in componentStyles.

Return values
static

getBaseProperties()

Get the base properties common to all components for JSON serialization.

protected getBaseProperties() : array<string, mixed>
Return values
array<string, mixed>

        
On this page

Search results