How to add custom event to Media Player during play?

hi

I have Image Sequence Source(0~300) and Media Player to control it.

I want this sequence to go to 240 and loop 121~240 until some bool becomes false. After that it will play through 300 and end.

I cant seem to find a way to trigger some event at 240th frame to seek media player to 121th frame.

Any ideas on doing this?

Thanks!

Hey @getarobo
Unfortunately Media Player doesn’t have a way to loop at a specific segment and continue when coding logic requires. Though due to your question I was testing running media player through sequencer and it kinda works. There are some weird glitches that exists but I believe you will be able to figure that out. I am sharing gifs to showcase that.
ffbb9e839385cb450c9c2ffe46e71908

Hey @zer0chi!

Yeah I tried using sequencer and get the event but the problem was I needed sequencer to go back to certain point to loop. Ive been searching on how to do this but was unable to figure out.

I am looking into IMediaPlayer.cpp 's TickInput(). Engine seems to use this to trigger EndReached() event.

Thanks for the help! I will update on what I find :slight_smile:

well I just added a Actor class that checks time of media player and handles the logic. OnEndReached didnt work for me for some reason so i just added my own.

I tried to override TickInput from imgmediaplay.h but cant figure this out :stuck_out_tongue:

This might not be the most accurate solution but seems to work fine for my image sequence media player

.h
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEndReached, int
...
class MY_API AMediaManager : public AActor
...
	PROPERTY(EditAnywhere, BlueprintReadWrite)
	UMediaPlayer * MediaPlayer;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool LoopOn = true;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool IsPlaying = false;
	UPROPERTY(BlueprintAssignable)
	FOnEndReached OnEndReached;


.cpp
void AMediaManager ::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if(MediaPlayer && MediaPlayer->IsPlaying())
	{
		if(LoopOn && MediaPlayer->GetTime().GetTotalMilliseconds() > 8000)
		{
			ty0_MediaPlayer->Seek(FTimespan(0,0,4));
		}
		if(MediaPlayer->GetTime().GetTotalMilliseconds() > 10000)
		{
			MediaPlayer->Pause();
			isPlaying = false;
			OnEndReached.Broadcast(0);
		}
	}
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.