Inside the TV_Blueprint, click on the Event Graph tab below the Main Toolbar.
In the Components window, select the Box. In the Details panel, add both the On Component Begin Overlap and On Component End Overlap Events.
This will generate events which we can use to enable the player to press a button and affect the TV Blueprint.
In the graph, right-click and add Get Player Controller, Enable Input, and Disable Input nodes, connecting them as shown.
When the player enters the box's collision volume, they will be able to affect this Blueprint with keyboard input. After leaving the volume, they will not.
In the graph, right-click and add an O and P keyboard event and two Flip Flop nodes. Connect as shown.
We are going to set it up so that when the player presses the O key, we will turn on or off the TV, and the P key will pause or resume playback.
In the My Blueprint panel, create a variable called MediaPlayerForVideo.
In the Details panel for the new variable, set the Variable Type to Media Player Object Reference, Instance Editable and set the Default Value to MediaPlayer_01.
In order to play our video content at runtime, we need to tell our Media Player Asset to open a Media Source. Before we can do that we need a reference to the Media Player we want to talk to and by making this Instance Editable, we can define which Media Player we are going to talk to (allowing us to have multiple players and content in our level).
Hold Ctrl and drag the MediaPlayerForVideo variable into the graph, then drag off it and use the Open Source function call.
On the Open Source node, set the Media Source to Video_01, then right-click on it and select Promote to Variable. Call this variable SourceToOpen.
Here, we are creating a variable for the Media Source so that we may choose a different Media Source to play.
Setting the value of a property, then choosing Promote to Variable will automatically create a variable and assign your value as the Default Value.
On the SourceToOpen variable, enable the Instance Editable option.
This will enable us to set which source to open for each instance of the TV we have placed in the Level.
In the graph, off the Media Player For Video node, use the Close function call and connect each to the FlipFlop node.
When the player presses the O key, they will open the specified Media Source (turning on the TV). Pressing O again will close the Media Player (turning the TV off).
Our Media Player is set to Play on Open. Therefore, when we open a source, the player will start playing the source content automatically.
For the P keyboard event, add the MediaPlayerForVideo variable then drag off it and call both Pause and Play functions, connecting them as shown.
Similar to how we open a Media Source, when the player presses the P key, they will pause the Media Player, and pressing P again will resume play.
Close the TV_Blueprint, then in the Content Browser, drag the TV_Blueprint into the Level and resize using the transform tools as desired.
In the Details panel, you will see all of the exposed properties that we can change for our TV.
These properties will enable us to change the video/audio associated with the TV, but first, we need another Media Source.
Right-click inside the Content Browser in the Content/Movies folder, then, under Media, select Stream Media Source and call it Video_2.
In addition to local media files, Media Framework also supports streaming video (in a [supported](Engine\MediaFramework\TechReference) format) from the Internet with the Stream Media Source Asset type.
Open the Video_2 Asset, then right-click this Sample Video Stream and Copy link address then paste the link in the Stream URL field.
As of version 4.18, YouTube links are not yet supported. Please see the [Media Framework Technical Reference](Engine\MediaFramework\TechReference) page for supported formats.
Inside the Content Browser in the Content/Movies folder right-click and create another Media Player Asset.
We can use this Media Player to play content on an additional TV inside the Level.
In the Create Media Player window, make sure to enable Video Output Media Texture Asset, then call the Media Player MediaPlayer_02.
This will automatically create and name our Media Texture and Media Player Assets.
In the Level, create a copy of the TV_Blueprint. In the Details panel, change the properties below.
Set the following:
Texture for TV - MediaPlayer_02_Video
Media Player for Sound - MediaPlayer_02
Media Player for Video - MediaPlayer_02
Source to Open - Video_2
Here we are changing which Media Player, Media Texture, Media Sound and Media Source to open to our newly created Media Framework content and streaming video.
Click the Play button from the Main Toolbar to play in the Level.