UE4 video playback (Media Player)

1. Video Play Beginning

First drag in the video you want to play.

insert image description here
Create Media Player and Media Texture.

insert image description here
insert image description here
Create Material and change the material to User Interface.

insert image description here

insert image description here
In the UI interface, create an Image and load this material.

insert image description here
Add the Media Sound component to the character Pawn interface and drag the small TV into it.

insert image description here
The playback can be completed by implementing the corresponding playback logic on the corresponding UI interface.

insert image description here

2. Functions that Media Player can call

2.1 Set the sound volume

Note that the function of Media Sound needs to be called here , not that of the small TV.

insert image description here

2.2 Set play and close

insert image description here

2.3 Drag the progress bar

Note : If Seek is called too frequently, there will be freezes, and high brushing cannot be achieved.

insert image description here
The time here can be GetTotalXXXconverted into seconds, milliseconds, etc., for the calculation of the progress bar.

insert image description here

2.4 Set playback rate

insert image description here

2.5 Set whether to play in loop

insert image description here

2.6 Set mirror image

Flipping the Image is a mirror image, that is, changing the rendered X to -1.

insert image description here

3. Other self-implemented functions

3.1 Display playing time

Playing time is real-time and updated, implemented in Event Tick.

insert image description here
insert image description here

3.2 The progress bar displays the playback screen

Use another same container as the display screen, and add it to the original video progress bar.

insert image description here
insert image description here
In the original video, when the mouse is hovered Set Time by Event, it is frequently called to achieve the effect of real-time images.

insert image description here

insert image description here

3.3 Show and hide

  • Visable : Physical collision and visible
  • Collapsed : collapsed, may change the original layout
  • Hidden : hidden, will not change the original layout
  • Not Hit-Testable : Visible, but no click physics collision
  • Note: Some video functions use Collapsed, such as the collision box that needs to be hidden but does not affect the layout. Hidden, the box that affects the layout. Not Hit-Testable, such as the real-time playback screen displayed by the video function, needs to be visible and cannot have physical collisions.

insert image description here
A box is used here to clear all related explicit and hidden operations.

3.4 Picture-in-picture and full screen

Picture-in-picture and full-screen are relatively simple, and both use the same Media Mat to achieve synchronization. You only need to pass in the values ​​that need to be synchronized.

insert image description here

3.5 Video Definition

Because the Render Target can adjust the video definition, but the Media Player cannot. Therefore, we can adjust the video definition by continuously drawing the Media Player to the Render Target.
First create the Render Target.

insert image description here
insert image description here
Use the original material to Draw Material to Render Targetcontinuously draw to the material of the Render Target.

insert image description here
Using the corresponding Render Target material is the corresponding resolution size, and the way to adjust the resolution is to adjust the sampling.

insert image description here

4. Final effect

Finally, a video playback UI imitating station B was realized.

insert image description here
insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/qq_45617648/article/details/129792802