[UMF, 4.7.5] MediaPlayer->Close() is not exposed to Blueprint

The UMF MediaPlayer has OnMediaOpened and OnMediaClosed delegates, but there is no Close() command available to Blueprint. We solved this locally by creating a static function (globally available in blueprint) with the following lines of code:

if (IsValid(Player))
{
TSharedPtr IPlayer = Player->GetPlayer();

	IPlayer->Close();
}

Works like a charm.

Thanks, I will make this change in the Master branch right after our 4.8 branch is complete. This will then be available in 4.9.

UPDATE
This is now checked in (GitHub commit)

Oh, while I remember! I noticed that doing this Close() call on a player that has not opened a URL, or is not playing yet, may crash the device. So an additional check on the player may be needed. Thanks gmpreussner!

Oh, that’s not good - Close() should never crash. On which platform did this happen? Windows?

Do you have a callstack or log file?

This is on Android, not tested on iOS. There are several other UMF problems on mobile, probably related to JNI.

I did not fetch any logs when it happened as I only focused on not getting the crash. I only remembered seeing something related to closing the media player in the stack trace and I remembered I put a Close() on initializing the player. There’s a small problem on PC where the video may continue to play in the editor and it messes with the regular playback.

I had that close just to make sure the media was “reset” on PIE. Then it crashed on device so I had to remove it.

Hi again gmpreussner. Sorry for the delay. I just tried to reproduce the problem, to give you logs, and I found out two specific details that are needed to get it to crash.

  1. The MediaPlayer must start / be saved with an empty URL.
  2. The Close() command must accidentally run via the Tick function. Directly or through a function later down the line.

When these conditions are met, even if the Close() is only run once, it will crash on play or on start. It’s a very specific scenario for it to crash.

I think that I accidentally had the Close() and the Play() executing close to each other and causing some conflict. The log is attached below, which doesn’t say much, but I think I essentially did the worst thing I could do with the MediaPlayer.

I did not test this on the device, but I’m certain it is related to a MediaPlayer that starts with an empty URL rather than a default existing video.

VisualStudio crash callstack

Your callstack seems to be ending inside your own code. Are you able to see this crash in the Visual Studio debugger?

Sorry gmpreussner, I was stupid enough to not check if the IPlayer is valid. The crash was because I got a null pointer. (it’s the same code as in the original post)

Thanks for implementing the Close() function!