Search Results for

    Show / Hide Table of Contents

    Playlist Media Player

    alt_text

    The PlaylistMediaPlayer component extends the MediaPlayer by allowing a playlist of multiple media to be played. Optionally visual transitions can be specified between the media items. Audio is also cross-faded when transitioning.

    This component uses two MediaPlayer instances, so it is more expensive than simply using a single MediaPlayer.

    Note

    When playing very high resolution videos (eg in VR), this component may not work on mobile systems as they usually have limited hardware video decoders and memory and this component requires two videos to be in memory at once.

    Scripting
    PlaylistMediaPlayer pmp;
    
    // Setup
    pmp.LoopMode = PlaylistMediaPlayer.PlaylistLoopMode.Loop;
    pmp.AutoCloseVideo = true;
    pmp.AutoProgress = true;
    pmp.DefaultTransition = PlaylistMediaPlayer.Transition.Zoom;
    pmp.DefaultTransitionDuration = 2.0f;
    pmp.DefaultTransitionEasing = PlaylistMediaPlayer.Easing.Preset.InOutCubic;
    
    // Query the playlist
    int playlistSize = pmp.Playlist.Items.Count();
    MediaPlaylist.MediaItem currentItem = pmp.PlaylistItem;
    if (currentItem != null)
    {
        Debug.Log("Current media is at " + currentItem.mediaPath.GetResolvedFullPath());
    }
    int playlistItemIndex = pmp.PlaylistIndex;
    
    // Build the playlist
    pmp.PlaylistItems.Clear();
    MediaPlaylist.MediaItem item = new MediaPlaylist.MediaItem();
    item.mediaPath = new MediaPath("myvideo.mp4", MediaPathType.RelativeToStreamingAssetsFolder);
    item.progressMode = PlaylistMediaPlayer.ProgressMode.OnFinish;
    item.isOverrideTransition = true;
    item.overrideTransition = PlaylistMediaPlayer.Transition.Black;
    item.overrideTransitionDuration = 1.0f;
    item.overrideTransitionEasing = PlaylistMediaPlayer.Easing.Preset.Linear;
    pmp.Playlist.Items.Add(item);
    
    // Manipulate volume
    pmp.AudioVolume = 0.5;
    pmp.AudioMuted = true;
    
    // Control playback
    pmp.Pause();
    pmp.Play();
    if (pmp.CanJumpToItem(2))
    {
        pmp.JumpToItem(2);
    }
    if (!pmp.NextItem())
    {
        Debug.Log("Can't change item");
    }
    if (!pmp.PrevItem())
    {
        Debug.Log("Can't change item");
    }
    
    Properties
    Property Function
    Player A The first MediaPlayer component
    Player B The second MediaPlayer component
    Auto Progress Enable the playlist to progress to the next item automatically, or wait for manual trigger via scripting
    Loop Mode None: Do not loop the playlist when the end is reached.
    Loop: Rewind the playlist and play again when the each is reached
    Auto Close Video Closes videos that aren't playing. This will save memory but adds extra overhead
    Next The transition to use when progressing to the next video
    Easing The type of easing to use for the transition
    Duration The duration of the transition in seconds
    Pause Previous Causes the previously playing video to pause at the end of the transition which improves performance

    Playlist Items

    alt_text

    Each item in the playlist needs to be specified.

    Property Function
    File Location Location of the file
    File Path Path or URL of the file
    Loop Loop the playback
    Start Mode Immediate (default): start playback immediately
    Manual: require API or GUI trigger to start playback
    Progress Mode On Finish (default): the playlist will progress when the media reaches the end<br/.>Before Finish: the playlist will progress at some interval before the end of the media is reached. This is useful when cross-fading
    Manual: the playlist will only progress by the API
    Progress Time Seconds When Progress Mode is set to Before Finish this duration in seconds is used to specify how long before the end of the media duration the playlist will progress to the next item.
    Override Transition Enables a custom transition to be specified for this media item
       Transition The custom transition to use for this media item
       Duration The duration in seconds for the custom transition
       Easing The easing type for the custom transition
    In This Article