MediaItem

The playlist API is based on MediaItems, which can be conveniently built using methods outlined below.

 

Simple media items

 

A media item can be easily created by calling the following methods:

// Creates a new media item with a file located in the StreamingAssets folder
MediaItem mediaItem = new MediaItem(UriType.StreamingAssets, filename);


// Creates a new media item with a remote url

MediaItem
 mediaItem = new MediaItem(UriType.RemoteUri, url);

 

A media item with a pre-configured metadata can also be created:

MediaMetadata mediaMetadata = new MediaMetadata();
...configure MediaMetadata
MediaItem mediaItem = new MediaItem(uriType, mediaUri, mediaMetadata);

 

Methods

 

using NativeMediaPlayerCenter;

MediaItem MediaItem(string uri, MediaMetadata metadata) Create a MediaItem.
void Sync() Send the MediaItem to the native side, so that it can be readible from the native plugin. Use this fuction before preparing the native player.

 

Properties

int Id The index number of the MediaItem
UriType Path An enum value that indicates where your sources are located.

short UriType.StreamingAssets = 0
short UriType.RemoteURL = 1
string MediaUri Uri path of the MediaItem.
bool HasCustomMediaMetadata (read-only) Returns true if the MediaItem is set to use a customized MediaMetadata and does not retrieve from the media file
string Title Title of the MediaItem.

💡 Refers to following native parameters
METADATA_KEY_TITLE (Android)
MPMediaItemPropertyTitle (iOS)
string Artist Artist of the MediaItem.

💡 Refers to following native parameters
METADATA_KEY_ARTIST (Android),
MPMediaItemPropertyArtist (iOS)
string AlbumTitle Album title of the MediaItem.

💡 Refers to following native parameters
METADATA_KEY_ALBUM (Android),
MPMediaItemPropertyAlbumTitle (iOS)
string AlbumArtist Album artist of the MediaItem.

💡 Refers to following native parameters
METADATA_KEY_ALBUM_ARTIST (Android),
MPMediaItemPropertyAlbumArtist (iOS)
string Genre Genre of the MediaItem.

💡 Refers to following native parameters
METADATA_KEY_GENRE (Android),
MPMediaItemPropertyGenre (iOS)
string ReleaseDate Release date of the MediaItem.

💡 Refers to following native parameters
METADATA_KEY_DATE (Android),
MPMediaItemPropertyReleaseDate (iOS)
Sprite Artwork Artwork of the MediaItem.

💡 Refers to following native parameters
METADATA_KEY_ART (Android),
MPMediaItemPropertyArtwork (iOS)

 

Mono Media Item (MonoMediaItem.cs)

 

Mono media item is a custom inspector embeded version of public class MediaItem. It can be used when NativeMediaPlayer is initiated with only one media item.