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

Playing Platform Specific Media

Choose your OS:

If you are working on a multi-platform project, there may be instances where you want to play platform specific media. For example, you may want a specific movie to play when playing on PlayStation 4 (PS4) and a different movie to play when playing on the Xbox One. Or you may be using the same type of media, but it is encoded differently for performance reasons and want those different formats to play on different platforms.

With the Platform Media Source asset, you can determine which Media Source assets should play based on the platform it is running on. When you open/play the Platform Media Source, it will look at which platform you are currently on and play the assigned Media Source automatically.

In this how-to, we create a Platform Media Source and assign two different Media Sources for Android and Windows platforms.

PlatformHero.png

Steps

For this how-to we are using the Blueprint Third Person Template project with Starter Content enabled. We are also using two sample videos which you can download by right-clicking this Platform Videos link and extract the contents on your computer.

  1. In the Content Browser expand the Sources Panel and add a new folder called Movies then right-click on it and Show in Explorer.

    Platform_01.png

  2. Drag the sample videos or your desired media files into the Content/Movies folder of your project.

    Platform_02.png

    If you want to package and deploy your project along with any media files, you will need to place them inside the Content/Movies folder of your project.

  3. In your project under the Content/Movies folder of the Content Browser, right-click and under Media select File Media Source and name it Android_Movie.

    Platform_03.png

    Here we are creating a Media Source asset that the Platform Media Source asset can point to and use if it is running on an Android device.

  4. Create another File Media Source asset and call it Windows_Movie.

    Platform_04.png

  5. Open the Android_Movie Media Source, then for the File Path use the Gideon_720x480 (or your desired video) and select Open.

    Platform_05.png

    For our Android movie, we are using a .3GP video file which is better suited for playback on Android devices while our Windows movie is an .MP4 file.

  6. Open the Windows_Movie Media Source, then point the File Path to the Infiltrator Demo (or your desired video) and select Open.

  7. Right-click in the Content/Movies folder then under Media, select Platform Media Source and call it Platform_Source.

    Platform_06.png

    Now that we have multiple Media Source assets, we can define which Media Source is to be played on which Platform with the Platform Media Source asset.

  8. Open the Platform_Source, then under Android select the Android_Movie and under Windows select the Windows_Movie.

    Platform_07.png

    In our example we are using two different videos. However, you can use the same video that is encoded differently or in a different format for use with different devices. You may also use different Media Source types, for example, on Windows you may elect to use a Media Stream to pull content from a website instead of using a file on disk.

  9. Right-click in the Content/Movies folder then under Media, select Media Player.

    Platform_08.png

    We still need to use a Media Player to open and play our Platform Media Source asset.

  10. In the Create Media Player window, enable the Video output Media Texture asset option then click OK and call the asset Media Player.

    Platform_09.png

    This will automatically create a Media Texture associated with this Media Player that we can use inside a Material . We can then take that Material and apply it to a mesh in our Level to play our content on.

  11. Inside the Media Player asset, double-click on the Platform_Media asset in the Media Library window.

    Platform_10.png

    Double-clicking on the Platform_Source asset will start playback of only the Windows assigned Platform Media Source (since we are running on the Windows platform). Through Blueprint or C++, we could open the Android_Movie Media Source for playback however when we open the Platform_Source, only the Media Source assigned to Windows will play. Also, the Play on Open option is enabled by default which will allow the Media Player to start playback of whatever Media Source is opened.

  12. In the Main Editor window, from the Modes panel under Basic, drag a Plane into the Level and resize as desired then drag the MediaPlayer_Video texture onto it.

    Platform_11.png

    By dragging the Media Texture asset onto the Static Mesh in the Level, a Material is created and applied and will playback our media.

  13. With the Plane selected, in the Details panel add a Media Sound component with the Media Player option set to use your MediaPlayer asset.

    Platform_11b.png

  14. From the Main Toolbar, click the Blueprints option then select Open Level Blueprint.

    Platform_12.png

  15. In the MyBlueprint panel create a variable called MediaPlayer of the Media Player Object Reference type then assign your MediaPlayer as the Media Player to use.

    Platform_13.png

    This creates a reference to your Media Player asset which you can then use within Blueprint and call actions on.

    In order to set the Default Value for the variable, you may need to first click Compile to compile the Blueprint.

  16. Hold Ctrl and drag the MediaPlayer variable into the graph, right-click and add a 1 keyboard event and connect to an Open Source node pointing to the Platform_Source.

    Platform_14.png

    Here we are telling our Media Player to open the Platform Media Source asset which is set to open other Media Source assets based on which platform it is being run on.

  17. Close the Level Blueprint then click the Play button to play in the Editor.

End Result

When you play in the Editor, pressing the 1 key will open the Windows-defined Media Source inside the Platform Media Source.

If you were to deploy this project to an Android Device, the Android assigned Media Source asset would play.