Animated artwork for the media item with video and preview support.
The following example shows how to attach animated artwork to a content value:
```swift
let content = MusicContent(
id: track.id,
songTitle: track.title,
artistName: track.artist,
albumName: track.album,
type: .audio,
duration: .finite(track.duration),
artwork: Artwork(id: track.artworkID) { size in
let data = await loadArtworkData(size: size)
return try ArtworkRepresentation(data: data)
},
animatedArtwork: AnimatedArtwork(
id: "animated-789",
supportedAspectRatios: [.square, .tall],
preview: { size, ratio in
let data = await loadPreviewData(size: size, ratio: ratio)
return try ArtworkRepresentation(data: data)
},
video: { size, ratio in
await loadVideoURL(size: size, ratio: ratio)
}
)
)
```
Members (4)
get · iOS 27.0+
supportedAspectRatios
TypeScript
get supportedAspectRatios(): Array<AnimatedArtwork_AspectRatio>
Swift declaration
let supportedAspectRatios: [AnimatedArtwork.AspectRatio]
The aspect ratios this artwork supports.
The system requests preview and video assets for each supported ratio. Provide at least one ratio.
get · iOS 27.0+
compatibleAspectRatios
TypeScript
static get compatibleAspectRatios(): Array<AnimatedArtwork_AspectRatio>
Swift declaration
static let compatibleAspectRatios: [AnimatedArtwork.AspectRatio]
The aspect ratios compatible with the current device.
Creates an animated artwork whose preview and video assets load on demand.
- Parameters:
- id: A unique identifier for this artwork.
- supportedAspectRatios: The aspect ratios your app supports.
- previewProvider: A closure that loads a preview image for the specified size and aspect ratio.
- videoProvider: A closure that provides a URL to a video file for the specified size and aspect ratio.
get · iOS 27.0+
id
TypeScript
get id(): string
Swift declaration
let id: String
A unique identifier for this animated artwork asset.