Media Framework Overview

Media Framework uses several assets to enable the playback of videos inside Unreal Engine 4. Videos can be scrubbed, paused, or rewound inside a Media Player asset, as well as controlled through C++ or Blueprints Visual Scripting . Whether you want a surface in your level playing a video, or you want to create a UMG UI Designer interface to give players control over your video playback, you will first need to specify the Media Source so that the engine can locate your media asset.

Media Source Types

There are several different Media Source assets that you can use to define where the media is coming from. Whether you have a file that is included as part of your project, streaming media from a website, or using platform specific media, you will need to define a source before you can play the video. You can add a Media Source inside the Content Browser by clicking the Add New Button then specifying which source type you want under the Media section.

MediaSource.png

Please see the Media Framework Technical Reference page for information on supported file types and URLs.

File Media Source

MediaSource_File.png

The File Media Source asset is used for media files stored on your device or in a shared local network file. The File Path section is where you specify where the media file resides. While a media file can exist anywhere, it's typically a good practice to move your media files to the Content/Movies folder of your project and then point to the media file. This will ensure that your media is packaged correctly with your project. You will also see a yellow exclamation point (as shown above) when pointing to a file outside of this location as a warning.

This type of source asset can be used to load the entire media file into memory and play it from there by enabling the Precache File option (under the Advanced Options section). Based on the size of your file, caching time may vary, so take that into consideration when choosing this option. Each File Media Source asset can have its native media player plug-in overridden on a per platform basis (depicted below) or the player plug-in can be seleclted automatically.

PlatformOverride.png

Please see the Playing Videos in a Level how-to for working with File Media Source assets.

Stream Media Source

MediaSource_Stream.png

This Stream Media Source asset takes a URL as the source of your media, and pulls it from the internet. Currently, linking to a YouTube or DailyMotion style URL is not supported, and you will need to link directly to a hosted file. Like the File Media Source asset, Stream Media Source assets can have their player plug-in overridden on a per platform basis or the player plug-in can be selected automatically.

Please see the Streaming Videos in a Level how-to for working with Stream Media Source assets.

Platform Media Source

MediaSource_Platform.png

The Platform Media Source asset supports overriding a Media Source on a per-platform basis. For example, supppose you want a particluar video to play only on Android Devices or only on PS4. Inside the Media Sources section, you can designate which videos play on which platforms. Leaving the Media Source blank will cause the Default Source to be used.

Media Playlists

While you can play Media Source assets individually, the Media Playlist asset can play multiple Media Sources in order. After creating a few Media Source assets, you can add them to a Media Playlist, which will automatically cycle through and play each asset in the order you define. You can create Media Playlists inside the Content Browser from the Add New Button under the Media section.

MediaPlaylistButton.png

In the Media Playstlist window (pictured below), under the Playlist section, you can define the source assets to include and specific the playback order. Any Media Source assets you have created will be displayed in the lower Media Library window which you can Double-click on to add to the end of the playlist.

CustomizedPlaylist.png

Media Playlists can use a mixture of each Media Source type and playback in order unless specified through Blueprint Script.

Please see the Working with Media Playlists how-to for working with Media Playlist assets.

Media Sound Waves

In order to hear audio associated with a video, you will need to create a Media Sound Wave asset.

MediaPlayerSound.png

From the Add New button under Media, select the Media Sound Wave asset.

MediaPlayerSoundWindow.png

The Media Sound Wave asset provides Curve, Debug, Concurrency and Attenuation settings that can be adjusted to define how the asset is processed. When linked to a Media Player asset, audio attached to a video source will automatically play back along with the video. Typically, you can leave the default settings for a newly created Media Sound Wave asset. However, if you need more control over how the sound is perceived, you can adjust the Concurrency and Attenuation settings.

Please see the Audio and Sound section for more details on working with audio in Unreal Engine 4.

Media Textures

Media Texture assets are used for rendering video tracks from Media Player assets.

MediaTexture.png

While Media Sound Waves provide the audio, Media Textures provide the visuals from your media source assets. Media Texture assets can be included within Materials that can then be applied to meshes in your level such as a billboard, TV or monitor to make it appear as if the video is playing on that object within the game world.

MediaTextureWindow.png

Above, a Material including a Media Texture asset has been created and applied to a static mesh in the level. Inside the Texture Editor , the Media Texture displays the same playback position as it appears in the Material in the level. In addition to the standard Texture Properties , Media Textures accept X and Y Axis Addressing values of Clamped, Mirror or World values.

Please see the Media Framework How-To section for guides on how to setup and use Media Textures to play videos.

Media Player Assets

Once you have a Media Source or Media Playlist, you can play back the asset using a Media Player asset. The Media Player asset requires the use of a Media Texture to produce the video playback and a Media Sound Wave to produce the audio associated with the video. You can create Media Player assets inside the Content Browser from the Add New Button under the Media section.

MediaPlayer.png

When creating Media Player assets, the Create Media Player window (pictured below) will appear asking if you would also like to create and link assets to the Media Player. This allows you to automatically create and assign a Media Texture and Media Sound Wave associated with the Media Player asset you are creating.

CreateMediaPlayer.png

Double-clicking on a Media Player asset will open the Media Player Window:

MediaPlayerWindow.png

Inside the Media Player Window, you can playback and preview any Media Source assets you have created (created source media are displayed the Media Library panel). You can play, pause, rewind, or skip to the beginning or end of a video from the toolbar across the top. Any Media Playlists that are currently playing videos will be displayed in the upper right Playlist window.

In the lower-right Details panel, you can define options for Playback or assign the Sound Wave and Video Textures (or an Image Texture) associated with the Media Player. There is also an Info panel which will display info about the source such as the stream type, codecs, sample rate, dimensions and more.

Media Assets & Scripting

Once your Media Player asset is set up and linked with the appropriate assets, it can be played during a game session. In order to play media in-game, you will first need to open the Media Source asset through Blueprint or C++. To do this, create a Variable inside any Blueprint that contains a reference to your Media Player asset.

MediaPlayerDetailsSet.png

With a reference to your Media Player defined, you can then call an Open function based on the type of media source.

MediaPlayerOpen.png

Option Description
Open Playlist Opens the first media source in the specified play list.
Open Playlist Index Opens a specific media source within a specified play list.
Open Source Opens the specified media source (File Media, Stream Media or Platform Media).
Open URL Opens the specified media URL.
Reopen Reopens the currently opened media or play list.

Newly created Media Player assets have the Play on Open option enabled by default which means when you open a Media Source it will start playing the video automatically. The Play on Open checkbox is a convenience, but not strictly required. If you do not want to automatically play the media once it has been opened successfully, you can also hook into the OnMediaOpened Blueprint event. If you uncheck the Play on Open option (pictured below), you will then need to call the Play function on a Media Source after it has been opened.

UncheckPlayOnOpen.png

Below on Event BeginPlay, we open a Media Playlist and play the Media Player when the Right Mouse Button is Pressed.

PlayWhenPressed.png

If you are not automatically playing a Media Source on open and are using the Play function to start playback, it is advised that you do not chain the Play call directly after an Open Source or Open Playlist call. This is because it may take some time for the Media Source to open and the Play command will just return false and the movie will not play as expected.

You can call other functions from a Media Player reference such as Binding Events to various states of playback (such if the video is paused or if the video ends). You can also call several different Functions off a Media Player reference like checking if a video can be paused, is a video playing, is a video set to loop, accessing play rate information and others.

MediaPlayerNodes.png

To see these options, drag off a Media Player reference then look under the Media Player section of the Blueprint Context Menu.