Explicitly open an image media source?

EDIT: Giving up. I’ve converted the image sequences to bink and everything works reliably. I’ve concluded there is a bug somewhere when opening multiple img file sources too quickly. Bink players aren’t having this problem.

I’m simplifying my previous question…

I have a number of media players opening image media sources. These sources are dynamically set during runtime, they cannot be built into the project.

The problem I’m having is that things are only working intermittently.

I set the image media source to the path of the sequence of PNG files:

On begin play, I have set up this event:

The execution path above to the right eventually leads to this:

So when the Update Event is executed, this event gets triggered. Unfortunately, while this message gets displayed on the output, the image sequence is often NOT ready to play.

While in PIE, I can explicitly open the image source - there’s a giant “open” button right there, and when you click it, everything starts to work, but there’s no “open” on the source in blueprints, there’s only the open on the media player (which I’m doing - first picture).

I wouldn’t see my message if the open was not successful, I’m supposing.

Driving me nuts… the worst part is it’s intermittent.

well, considering you have a bind delegate to the same media player object. then a delay. i wouldn’t be surprised if there’s a race condition there.

Not following. It’s bound once, not sharing that media player with anyone else. This is how event driven architecture normally works.

i know. and also event driven is prone to race conditions.

sometimes people use events where they don’t need to and it creates confusion.

ok, i assumed you did. since you mentioned you had “multiple sources”

your code really don’t show enough context for me to see the complete picture.

that OnOpen event, i’m not sure where is that being called.

also you bind to OnMediaOpened but you call mediaPlayer→Open on a different place (or so it seems by the contrived screenshots). you gotta be careful with the order in which you put those. i don’t see enough to tell if it’s correct or not. but i guess you know this already.

as well as the amount of times you bind to the event. I cant recall exactly but you can either assign an event or add to it. and i can’t recall if ue calls your event twice if you bind to it twice, but i think it does since in cpp there’s a function that specifically checks if it’s bound already before adding

tangential, on your 1st screenshot you connect mpath to “set” and setsequencepath. whatever code inside mpath will be evaluated once per node. you might consider using the path variable you just set.

what do you mean by that?

you have a delay until next tick there, which is also odd. the timing would affect the reliability.

i think that’s more of a preview.

the source doesn’t “open” is just the mp. the source tells the mp what to open. i wonder if trying to set the path might cause issues with image sequences though. usually the path is already set.

and you just assign the sequence.

there’s also an option on the mp to open an url which can also deal with files protocol iirc.

There’s nothing contrived about the images I posted - they are what was in the blueprint at the time and, yes, they crop out some proprietary information, but this is what the relevant parts look like.

Begin Play –> On Open

At some point, the user makes a selection, then what is shown in the first image is called.

“On Open” is called ONE time, it’s not re-bound to anything, and it’s not unbinding.

This blueprint is instanced 9 times, and in the outliner their Media Textures and File Sources are set to unique ones for each instance of the BP.

If I focus on only one instance at a time, everything seems to work fine. That’s the key, right there… the BP scripting works great if I only have once instance.

In the real world, though, I need to do at least three at a time - using an external interface, the user picks two teams, each with their own sequence (thus the MPath macro, which puts together a path based on the team name), and they pick what’s going to be shown between the two teams.

When I do three at a time, it rarely (but sometimes) works. If I do two at a time, if often, but not always works. If I do one, it’s like 99% working. And yes, this is all through the completely, 100% working, external UI.

In an extreme case, we might do all nine at the same time.

The strategy works 100% with bink instead of image sequences, which is what we are now going with. The problem is that removes the flexibility of last minute updates to logos, which is the broadcast environment we work in. If it was just me, it’s not a problem, but I’m just the developer, and making bink files is pretty easy, but I rely on another team to deliver the image sequences, and for whatever reason, that department was unable to set up bink on their Macs. Image sequences should work, theoretically. They are not that long, relatively speaking (180 frames), given the top of the line hardware we’re using.

W.R.T. opening img media sources via the Unreal UI, when I’m in PIE, using that Open directly in the img source interface after the external UI has set the values always works. So the issue becomes dynamically setting and opening multiple image sequences, even though there are multiple img media sources and media players that should have nothing to do with each other.

I DID try making a data table of fixed img media sources where the path was already set, and using that - but it still doesn’t seem to work, leading me to believe it still has to do with the media player opening the source which, programatically, is still a function of the source.

sorry i’ve used the wrong word. i meant something like constricted. as in, i need to see more of the code to have a proper understanding.

specially in relationship to each pieces of code.

thanks for the explanation that helps. i’m a bit rushed so i’ll only reply a bit right now.

yup i didn’t said it but i got from your previous posts that the issue happens with multiple instances and with image sequences. that makes sense. though i don’t have enough info to infer what could be the cause.

yup i got that. i’m trying to see if i can help a bit to give you back the option for images.

they are different backends, so it’s in their nature to behave differently.

not sure what that means.

yup i agree. the same thing i’ve assumed from before. that’s why i suggested that it’s likely a race condition of sorts or similar.

though at this point i’m not sure if it’s due to your code, or maybe a limitation on the image sequence backend. which i wouldn’t think.

i’m not sure i get exactly what you are thinking here. i understand the surface meaning.

i understand the surface meaning, but i don’t understand what you actually mean by that.

the function OpenSource is a function that belongs to the MP , the source is just an input data.

though even though it seems that the problem is with the source, i’d say that the code that has issues is more dependent on the mp. triggered by the mp i’d say. quite possibly on the backend. though i think focusing on one or the other at this point might not help.

i agree it’s happening only with the media player opening, and also with opening multiple, and also with image sequences.

i’d recommend doing a few tests. that pause and rewind and delay looks odd to me.

you know you can set the sequence to not autoplay on open right? or maybe you can set it on the MP. i’d recommend that.

can you try removing those auto play and rewind and see what happens?

w.r.t. = with respect to.

I do not see how a race condition can be created when each instance of the blueprint has their own, unique, Media Source, Media Texture, and Media Player.

It seems to me, and I could be wrong, but the media player is agnostic to the media, because it can be used for multiple types of sources, which would make the source responsible for opening and interpreting the data, and the media player just a controller.

There IS that “Open” control in the media source UI - what is it doing, if not calling the Media Source’s “open” function?

i see. well on a surface level that makes sense. but when you consider that it’s a backend, it might be using shared data and or state. that’s not unlikely. i have no idea, but it’s not unlikely.

it could also be a race condition with itself, i.e., a timing issue. which don’t seem to appear with one instance, but when using multiple it could be stressing the system enough to introduce the issue.

i think you’re trivializing the system too much, based on assumptions, if you check the code you’ll realize it’s actually more complex that it seems, and it interacts with several different other systems via delegates, asynctasks, and other callbacks.

https://github.com/EpicGames/UnrealEngine/blob/df42801f6a266711e1641d0058da4b0a0df711eb/Engine/Source/Runtime/MediaAssets/Private/Assets/MediaPlayer.cpp#L4

https://github.com/EpicGames/UnrealEngine/blob/df42801f6a266711e1641d0058da4b0a0df711eb/Engine/Source/Runtime/MediaUtils/Private/MediaPlayerFacade.cpp#L4

i agree with you, but like i said, i think the distinction is very fine grained, and depends on the level you’re seing it at. and i don’t think it really helps to solve the issue to make that distinction.

i really think we are just getting entangled in the weeds.

the mp is the controller right. and from that pov it’s the instigator and responsible.

the mp in fact is just an interface https://github.com/EpicGames/UnrealEngine/blob/df42801f6a266711e1641d0058da4b0a0df711eb/Engine/Source/Runtime/Media/Public/IMediaPlayer.h#L4

i haven’t checked the rest of the code, but it sounds extremely likely that each backend implements its own media player. and its own “open” inside which, anything is possible.

like i said the media source is just a struct, it does not do anything. you are just working via assumptions of what sounds logical, but it’s a bit off of how it actually works.

there’s no “open” in the media source https://github.com/EpicGames/UnrealEngine/blob/df42801f6a266711e1641d0058da4b0a0df711eb/Engine/Source/Runtime/MediaAssets/Public/FileMediaSource.h#L4

the media source does not do anything of interest. (unless your problem is with the path).

you’re getting confused. i’ve already tried to explain that what you see in the editor ui is just a debug option, and not really anything to do with your code.

so you can understand a bit better, it pretty much calls “open” in the media player. there is no open in the media source.

in any case, as you can see, none of these conversation actually gets us closer to solve the issue. except maybe to try to pinpoint and locate the issue with the corresponding backend. to which i recommend trying to modify your code and test on different scenarios to try to narrow down the side-effect.