MediaMetadata
The MediaMetadata class represents the metadata associated with a media item, including information such as the album, artist, title, artwork, genre, and release date. This class maps the metadata properties from both Android and iOS platforms to a unified representation.
Properties
Album
Description: The album title of the media item.
Android Equivalent:
METADATA_KEY_ALBUMiOS Equivalent:
MPMediaItemPropertyAlbumTitleType:
stringUsage:
string album = metadata.Album; metadata.Album = "New Album Title";
AlbumArtist
Description: The album artist of the media item.
Android Equivalent:
METADATA_KEY_ALBUM_ARTISTiOS Equivalent:
MPMediaItemPropertyAlbumArtistType:
stringUsage:
string albumArtist = metadata.AlbumArtist; metadata.AlbumArtist = "New Album Artist";
Title
Description: The title of the media item.
Android Equivalent:
METADATA_KEY_TITLEiOS Equivalent:
MPMediaItemPropertyTitleType:
stringUsage:
string title = metadata.Title; metadata.Title = "New Title";
Artwork
Description: The artwork associated with the media item.
Android Equivalent:
METADATA_KEY_ARTiOS Equivalent:
MPMediaItemPropertyArtworkType:
ArtworkUsage:
Artwork artwork = metadata.Artwork; metadata.Artwork = new Artwork { /* parameters */ };
Artist
Description: The artist of the media item.
Android Equivalent:
METADATA_KEY_ARTISTiOS Equivalent:
MPMediaItemPropertyArtistType:
stringUsage:
string artist = metadata.Artist; metadata.Artist = "New Artist";
Genre
Description: The genre of the media item.
Android Equivalent:
METADATA_KEY_GENREiOS Equivalent:
MPMediaItemPropertyGenreType:
stringUsage:
string genre = metadata.Genre; metadata.Genre = "New Genre";
ReleaseDate
Description: The release date of the media item.
Android Equivalent:
METADATA_KEY_DATEiOS Equivalent:
MPMediaItemPropertyReleaseDateType:
stringUsage:
string releaseDate = metadata.ReleaseDate; metadata.ReleaseDate = "2023-06-01";
Example Usage
Here's an example of how you might use the MediaMetadata class in your application:
using Glitch9.NativePlugins.NativeMediaPlayer;
using UnityEngine;
public class MediaMetadataExample : MonoBehaviour
{
void Start()
{
MediaMetadata metadata = new MediaMetadata
{
Album = "Greatest Hits",
AlbumArtist = "Famous Artist",
Title = "Hit Song",
Artist = "Famous Artist",
Genre = "Pop",
ReleaseDate = "2023-01-01",
Artwork = new Artwork { /* parameters */ }
};
Debug.Log($"Playing media: {metadata.Title} by {metadata.Artist} from the album {metadata.Album}");
}
}Last updated