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

Rewind & Fast Forward Playback

In addition to playing a video with Media Framework, you can grant players the ability to control the Playback Rate to rewind, pause or fast forward videos. In this how-to we allow the player to press a button to rewind, a different button to fast forward and another button to play a video playing in the level similar to below.

Steps

For this how-to we are using the Blueprint Third Person Template project with Starter Content enabled. You will also need a few Supported Video Files saved on our computer that you want to add to the playlist for playback. You can use your own or Right-click and download this Sample Video .

  1. In your project create a folder called Movies, then in explorer add your video to the Movies folder.

    ControllingPlayback_01.png

  2. Create a File Media Source (or any other source asset) and point the asset to your video.

    ControllingPlayback_02.png

  3. Create a Media Player asset called VideoPlayer and associated Media Sound Wave and Media Texture assets.

    ControllingPlayback_03.png

  4. Inside the Media Player asset, uncheck the Play on Open option.

    ControllingPlayback_04.png

  5. In the Content Browser under StarterContent/Shapes drag a Shape_Plane into the level.

    ControllingPlayback_05.png

  6. Use the Translate (W), Rotation (E) and Scale (R) tools to adjust the size and location of the Static Mesh as desired.

  7. Hold Ctrl then select both the Sound Wave and Media Texture assets and drop them on top of the Static Mesh in the level.

    ControllingPlayback_06.png

    This will automatically create a Material and apply it to the Static Mesh.

  8. From the Toolbar, click the Blueprints button and Open Level Blueprint.

    ControllingPlayback_07.png

  9. Add a Variable of the Media Player Reference type called MediaPlayer and set it to your VideoPlayer Media Player asset.

    ControllingPlayback_08.png

    You may need to Compile before you can assign the Default Value.

  10. Add an Event Begin Play node, your Media Player variable and use Open Source to open the MyVideo File Media Source asset.

    ControllingPlayback_09.png

  11. Add a 2 Keyboard Event with Pressed set to Play the MediaPlayer asset.

    ControllingPlayback_10.png

  12. Add 1 and 3 Keyboard Events both using Set Rate off the MediaPlayer asset and adjust each node's Rate value.

    ControllingPlayback_11.png

    By setting Rate to -1.0 this will play the video in reverse while a Rate of 2.0 doubles the forward playback speed, scrubbing forward.

    Currently you may experience audio synch loss when issuing commands to the Media Player asset. You can insert short delays between commands to allow the player has time to process them. We are aware of these issues and are investigating possible fixes to accompany future engine updates.

  13. Close the Level Blueprint and click the Play button to play in the editor.

End Result

When playing in the editor, the video playback will not initially start when the level is loaded. When the player presses the 2 key, the video will start playing. Pressing the 1 key, the video will start to rewind while pressing the 3 key fast forwards the video. The rate at which we rewind or fast forward is determined by the Rate value on the Set Rate node. Adjust those values to speed up the play back rate when going in reverse or forward.

While our example uses keyboard presses, you could use the same functionality within a User Interface built with UMG where the player clicks on a button to issue commands.

Other Considerations

The availability of some advanced playback features depends on the Media Source, as well as the used player plug-in. For example, not all Media Sources allow for seeking or changing the playback rate, and not all player plug-ins implement support for these features yet.

Some combinations of Media Sources and players allow for rate changes, but only for certain rate ranges, or the playback may be thinned (i.e. frames will skipped = choppy). Some playback features can be queried via Blueprint, for example CanPause, GetForwardRates, GetReverseRates. All playback functions (Play, Rewind, Pause, SetRate, etc.) provide a Boolean return value indicating success or failure of the desired operation.

There is also currently a limitation in the WmfMedia player plug-in for Windows that prevents chained calls of playback functions. For example if you string together a chain of commands like Play -> SetRate -> Pause -> SetRate -> Play like so:

Click for full view.

Your state machine for the Media Player will likely break and the only way to recover would be to re-open the Media Source or Playlist.

If you wish to chain calls, one possible workaround is to insert Delay nodes between each call in order to give the player enough time to process the current command.

ExampleChainDelays.png