Requirement: We hope to provide an event or function callback for the first frame image display when playing videos with Electra Player.
We are using Unreal’s officially recommended Electra Player for video playback support across all platforms.
Currently, the issue we are facing is: We have not found a callback for the first frame image display. We aim to pause world rendering once the image appears to improve performance.
So far, we have observed that videos without audio can be displayed promptly, whereas videos with audio tracks require a longer waiting time for audio-video synchronization (approximately 500ms). Is there an interface or event that can capture the moment when audio-video synchronization is complete and video playback begins?
Are you using the UMediaPlayer class for the playback? If so, you can try listening to Media Events via the OnMediaEvent() delegate on the object.
In this case, you can try listening to a combination of EMediaEvent::MediaOpened and EMediaEvent::PlaybackResumed. The first call to PlaybackResumed after MediaOpened would be the timing you are looking for in this case.
When the video includes an audio track, the image is not yet displayed at the moment the PlaybackResumed event is triggered. Our tests show that on mobile platforms, there is an additional delay of approximately 500ms. Is it possible to resolve this issue for videos with audio tracks?
Something that is precise like that would require some engine modifications.
You can add a delegate to the UMediaTexture to trigger just before the ENQUEUE_RENDER_COMMAND with a boolean to track whether the next frame should trigger the delegate.
This could be the most closest timing for your needs accounting for the minimal additional time for the render command itself to be processed and the texture rendered on screen.
If you intend to process the delegate on the render thread, you can also broadcast the delegate within the render command that is queued up.
For engine modifications like this, we can offer information about existing functionality, and we leave the details of the implementation to you.