RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
238 stars 29 forks source link

Play a clip with a specified time range #766

Open HolgerDurach opened 3 years ago

HolgerDurach commented 3 years ago

Is your feature request related to a problem? Please describe. In my application I often play only parts of a video, for example frame 100 till 250, then await the user to click on something in this frame, than the video continues until frame 400. With the UnityVideo player I listened to the frameReady event, with AvPro I guess I have to check in Update for the usedPlayer.Control.GetCurrentTimeFrames, right? Not sure if this call might be expensive or if I might miss my "target-frame" when the framerate is bad.

Describe the solution you'd like Perfect would for me be to have an option like player.Control.SetEndPlayFrame(int) at which the player pauses... or maybe something like an player.control.SendCustomEventAtFrame(int), so that i get informed when a specific frame was reached... or to have the same general "frameReady" event like the unityVideoPlayer has.

kahnivore commented 3 years ago

Hi @HolgerDurach

The GetCurrentTime method is not expensive, so there's no reason you can't use it. Something to note is that the frames won't always be accurate, it depends on the platform and how the video is encoded - so it might be better to convert to a time value rather than a frame, and have a bit of a buffer so that if you don't hit the exact frame it still works. There's also a function mediaPlayer.TextureProducer.GetTextureFrameCount(); - you could watch this value to see when the count has increased.

The feature you suggest is actually something we're working on including in a later release - which will enable you to play a clip with a specified time range - and possibly an event to signal the end of that clip. I'll add it has an enhancement here so that when we've implemented this you'll hear about it.