MediaItem
The MediaItem
class represents a single media item in a playlist and includes metadata and state information about the media. Below is a detailed reference for each property and method available in the MediaItem
class.
Constructors
MediaItem
Description: Initializes a new instance of the
MediaItem
class.Parameters:
UriType type
: The type of URI.string uri
: The URI of the media item.MediaMetadata metadata
(optional): Metadata associated with the media item.
Usage:
MediaItem item = new MediaItem(UriType.RemoteURL, "http://example.com/media.mp3");
Properties
Index
Description: Gets or sets the index of the media item in the playlist.
Type:
int
Usage:
int index = item.Index; item.Index = 1;
PlaylistIndex
Description: Gets or sets the index of the playlist to which this media item belongs.
Type:
int
Usage:
int playlistIndex = item.PlaylistIndex; item.PlaylistIndex = 0;
MetadataState
Description: Gets or sets the state of the metadata retrieval process.
Type:
MetadataState
Usage:
MetadataState state = item.MetadataState;
DownloadDirectory
Description: Gets or sets the download directory for the media item.
Type:
string
Usage:
string directory = item.DownloadDirectory; item.DownloadDirectory = "/path/to/download";
MetadataType
Description: Gets or sets the type of metadata retrieval.
Type:
MetadataType
Usage:
MetadataType type = item.MetadataType; item.MetadataType = MetadataType.Custom;
Metadata
Description: Gets or sets the metadata of the media item.
Type:
MediaMetadata
Usage:
MediaMetadata metadata = item.Metadata; item.Metadata = new MediaMetadata { Title = "New Title" };
Uri
Description: Gets the URI of the media item.
Type:
string
Usage:
string uri = item.Uri;
UriType
Description: Gets the URI type of the media item.
Type:
UriType
Usage:
UriType uriType = item.UriType;
Title
Description: Gets the title of the media item.
Type:
string
Usage:
string title = item.Title;
Artist
Description: Gets the artist of the media item.
Type:
string
Usage:
string artist = item.Artist;
Genre
Description: Gets the genre of the media item.
Type:
string
Usage:
string genre = item.Genre;
ReleaseDate
Description: Gets the release date of the media item.
Type:
string
Usage:
string releaseDate = item.ReleaseDate;
AlbumTitle
Description: Gets the album title of the media item.
Type:
string
Usage:
string albumTitle = item.AlbumTitle;
AlbumArtist
Description: Gets the album artist of the media item.
Type:
string
Usage:
string albumArtist = item.AlbumArtist;
Artwork
Description: Gets the artwork of the media item.
Type:
Artwork
Usage:
Artwork artwork = item.Artwork;
SerializedMediaItem
Description: Gets or sets the serialized representation of the media item.
Type:
string
Usage:
string serialized = item.SerializedMediaItem; item.SerializedMediaItem = "serialized_data";
Methods
RetrieveMetadata
Description: Retrieves the metadata for the media item.
Usage:
item.RetrieveMetadata();
SetMetadata
Description: Sets the metadata for the media item.
Parameters:
MediaMetadata metadata
: The metadata to set.
Usage:
item.SetMetadata(new MediaMetadata { Title = "New Title" });
MetadataWarning
Description: Logs a warning if metadata is not retrieved yet.
Usage:
string warning = item.MetadataWarning();
Example Usage
Here's an example of how you might use the MediaItem
class in your application:
using Glitch9.NativePlugins.NativeMediaPlayer;
using UnityEngine;
public class MediaItemExample : MonoBehaviour
{
void Start()
{
MediaItem item = new MediaItem(UriType.RemoteURL, "http://example.com/media.mp3");
item.Metadata = new MediaMetadata { Title = "Example Title", Artist = "Example Artist" };
Debug.Log($"Playing media: {item.Title} by {item.Artist}");
}
}
Last updated