Native Media Player
Glitch9 Inc.Main Docs.
  • Introduction
    • Native Media Player
    • Preparation
    • Initialization
  • Functionalities
    • Media Item
    • Media Metadata
    • Playlist
    • Media Events
    • UI Components
    • Android Settings
    • iOS Settings
  • Advanced
    • Manual Initialization
    • Creating Playlist at Runtime
    • Single Media Item Playlists
  • API Reference
    • MediaPlayer
      • Properties
      • Methods
    • MediaEvents
    • MediaItem
    • MediaMetadata
    • Playlist
    • Configuration Details
  • Support
    • FAQ
    • Troubleshooting
      • SeekTo (Seekbar) doesn't work
      • java.lang.NoClassDefFoundError
      • One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified
      • AndroidX Build Error: resource android:attr/lStar not found.
    • Update Logs
Powered by GitBook
On this page
  • Properties
  • Example Usage
  1. API Reference

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_ALBUM

  • iOS Equivalent: MPMediaItemPropertyAlbumTitle

  • Type: string

  • Usage:

    string album = metadata.Album;
    metadata.Album = "New Album Title";

AlbumArtist

  • Description: The album artist of the media item.

  • Android Equivalent: METADATA_KEY_ALBUM_ARTIST

  • iOS Equivalent: MPMediaItemPropertyAlbumArtist

  • Type: string

  • Usage:

    string albumArtist = metadata.AlbumArtist;
    metadata.AlbumArtist = "New Album Artist";

Title

  • Description: The title of the media item.

  • Android Equivalent: METADATA_KEY_TITLE

  • iOS Equivalent: MPMediaItemPropertyTitle

  • Type: string

  • Usage:

    string title = metadata.Title;
    metadata.Title = "New Title";

Artwork

  • Description: The artwork associated with the media item.

  • Android Equivalent: METADATA_KEY_ART

  • iOS Equivalent: MPMediaItemPropertyArtwork

  • Type: Artwork

  • Usage:

    Artwork artwork = metadata.Artwork;
    metadata.Artwork = new Artwork { /* parameters */ };

Artist

  • Description: The artist of the media item.

  • Android Equivalent: METADATA_KEY_ARTIST

  • iOS Equivalent: MPMediaItemPropertyArtist

  • Type: string

  • Usage:

    string artist = metadata.Artist;
    metadata.Artist = "New Artist";

Genre

  • Description: The genre of the media item.

  • Android Equivalent: METADATA_KEY_GENRE

  • iOS Equivalent: MPMediaItemPropertyGenre

  • Type: string

  • Usage:

    string genre = metadata.Genre;
    metadata.Genre = "New Genre";

ReleaseDate

  • Description: The release date of the media item.

  • Android Equivalent: METADATA_KEY_DATE

  • iOS Equivalent: MPMediaItemPropertyReleaseDate

  • Type: string

  • Usage:

    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}");
    }
}
PreviousMediaItemNextPlaylist

Last updated 11 months ago