Language:
Page Info
Skill Level:
Engine Version:
Related Pages

Working with Media Playlists

Suppose you have a series of videos that you want to playback in a specific order or you want to allow players to access videos within a specific series of videos. You can do so by using a Media Playlist asset which points to Media Source assets assigned in a predefined order.

In this how-to we create a Media Playlist and allow the player to playback each asset sequentially or access a specific asset inside the playlist through a key press.

For this how-to we are using the Blueprint Third Person Template project with Starter Content enabled. You will also need a few Supported Video Files saved on our computer that you want to add to the playlist for playback. You can use your own or Right-click and download these two sample videos: Video Example 1 and Video Example 2

Steps

  1. In the Content Browser expand the Sources Panel, then in the Content create a new folder called Movies.

    Playlist_00.png

  2. Right-click on the Movies folder and choose Show in Explorer then place your video files in the folder. Placing your video files inside the Content/Movies folder of your project will ensure the videos are properly packaged.

    Playlist_01.png

  3. Create two File Media Source assets (called Video_01 and Video_02) point the File Path to each respective video.

    Playlist_02.png

  4. Create a Media Playlist asset inside the content browser called MyPlaylist.

    Playlist_03.png

  5. Inside MyPlaylist, Double-click on each File Media Source to add it to the playlist. You can also use the + button to add an empty element which you can then assign your source media. In this example we are using File Media Source assets, however you can also include Stream Media Source assets in a Playlist.

    Playlist_04.png

  6. Create a Media Player asset called VideoPlayer.

    Playlist_05.png

  7. In the Create Media Player window, check Audio output SoundWave asset and Video output Media Texture asset. This will automatically create a Sound Wave and Media Texture asset linked to this Media Player asset which is needed for playback.

    Playlist_06.png

    Playlist_07.png

  8. In the Content Browser under StarterContent/Shapes drag a Shape_Plane into the level.

    Playlist_09.png

  9. Use the Translate (W), Rotation (E) and Scale (R) tools to adjust the size and location of the Static Mesh as desired.

  10. Hold Ctrl then select both the Sound Wave and Media Texture assets and drop them on top of the Static Mesh in the level. This will automatically create a Material and apply it to the Static Mesh.

    Playlist_10.png

  11. From the Toolbar, click the Blueprints button and Open Level Blueprint.

    Playlist_11.png

  12. Add a Variable of the Media Player Reference type called Media Player and set it to your VideoPlayer Media Player asset. You may need to Compile before you can assign the Default Value.

    Playlist_12.png

  13. Right-click in the Event Graph and add a 1 Keyboard Event, 2 Keyboard Event and 3 Keyboard Event.

    Playlist_13.png

  14. Ctrl drag in the Media Player variable, then drag off it and use Open Playlist Index and set the InPlaylist to MyPlaylist.

    Playlist_14.png

  15. Use Open Playlist for the 2 Keyboard Event with Index set to 1 and use Open Playlist for the 3 Keyboard Event.

    Playlist_15.png

  16. Close the Level Blueprint, then click the Play button to play in the level.

End Result

When playing in the editor, the video playback will not initially start when the level is loaded. When the player presses the 1 key, the playlist will start playing from the first video in the playlist. When pressing the 2 key, the video playback will jump to the second video in the playlist. When pressing 3, we are opening and playing the video from the start of the playlist which is the same as opening the playlist at index 0.

Our Media Player asset is set to Play on Open which is why each video is played when we call the open playlist function. If you want to open a Media Source but not start playback immediately, you can uncheck the Play on Open option inside the Media Player asset then use the Play function to play an open Media Source asset.

You can also navigate an opend playlist with the Next function (to pick the next item in the playlist) and Previous (to pick the previous item in the playlist). The Media Player also has a property called Shuffle that when enabled will pick a random item from the playlist when the next source is to be opened (also affects Previous and Next).