Media Metadata
The MediaMetadata
is designed to store detailed information about a media item. This includes various attributes that describe the media content, such as title, artist, album, artwork, genre, and release date.
Basic Properties:
Album: The album name of the media item.
AlbumArtist: The artist of the album.
Title: The title of the media item.
Artwork: The artwork associated with the media item, typically an album cover or thumbnail image.
Artist: The artist of the media item.
Genre: The genre of the media item.
ReleaseDate: The release date of the media item.
Usage Example
Here’s a simple example of how you might create and use a MediaMetadata
instance:
Metadata Retrieval
Depending on the MetadataType
, metadata can either be custom-defined or retrieved dynamically at runtime.
MetadataType Options
Retrieve:
Description: This type indicates that metadata should be retrieved dynamically at runtime. The system will attempt to fetch the metadata from the media file or a remote source.
Usage: Use this type when you want the media player to automatically gather information such as title, artist, album, and other details directly from the media file. This is useful for media files where metadata might change or is not predefined.
Example:
Custom:
Description: This type indicates that custom metadata has been defined and should be used. The metadata is set manually, often through the Unity inspector.
Usage: Use this type when you have specific, predefined information about the media item that you want to ensure is used. This is useful for cases where the metadata is known in advance and should not change.
Example:
How Media Metadata works
Below diagram illustrates the workflow for retrieving metadata for media items within the Unity Native Media Player plugin. The operations are divided between the Unity side (black) and the native side (green).
Get Metadata (MediaItem): The process begins with a request to get metadata for a media item.
Custom Metadata Check: The system checks if custom metadata exists.
If Yes: The custom metadata is returned.
If No: An error is thrown, and fallback metadata is returned.
Retrieve Metadata: If the metadata type is set to "Retrieved," the process moves to the native side.
Native Plugin Bridge: The request is passed through the native plugin bridge to the native metadata retriever.
Metadata Retriever (Native): The native side attempts to retrieve the metadata.
Retrieval Result: The result of the metadata retrieval is checked.
If Successful: The retrieved metadata is sent back to Unity.
If Failed: An error is thrown, and fallback metadata is used.
Title Check: Once the metadata is received, the system checks if the title is null or empty.
If Title is Empty: The filename is used as the title.
If Title is Not Empty: The metadata is successfully returned to Unity.
This workflow ensures that metadata is properly managed and retrieved, providing a robust system for handling media information in the Unity Native Media Player plugin.
Last updated