Once your Media Player asset is set up and linked with a Media Texture and (if the video has audio) a Media Sound component, it can be played during a game session.
In order to play media in-game, you will first need to create a reference to the Media Player asset through Blueprint or C++.
To do this, create a Variable of the Media Player variable type inside any Blueprint and set the Default Value of the variable to reference your desired Media Player.
With a reference to your Media Player defined, you can then call an Open function based on the type of media source.
Opens a media file at the specified file location on your computer.
Opens the first media source in the specified playlist.
Open Playlist Index
Opens a specific media source within a specified playlist.
Opens the specified media source (File Media, Stream Media or Platform Media).
Opens the specified media URL.
Reopens the currently opened media or playlist.
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.
You can uncheck this option inside your Media Player asset to have the source avoid playing when open and only start playing when explicitly called through Blueprint or C++.
If you do not want to automatically play the media once it has been opened successfully, you can also hook into the Play Blueprint event.
Above on Event BeginPlay, we open a Media Playlist and play the Media Player when the Right Mouse Button is Pressed only if it is ready to be played.
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. In these instances, you may want to use a binding event that is bound to the On Media Opened call.
Above, we open a Stream Media source and bind the Media Player to On Media Opened which will fire an event when fully opened that will play the media.
You can bind other functions with a Media Player reference to various states of playback (for example: 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, checking if a video is playing, if a video set to loop, and accessing play rate information (among other use cases).
To see these options, drag off a Media Player reference then look under the Media Player section of the Blueprint Context Menu.