Closed ghost closed 1 year ago
What sort of media are you trying to do this with and what is the media source?
Have you read our section on seeking and playback rate? https://www.renderheads.com/content/docs/AVProVideo/articles/feature-seeking-playbackrate.html
Yep, I've been through that link.
HLSL, 360 streamed video
You would be better off changing the playback rate for fast-forwarding and rewinding.
The first thing I tried was changing the playbackrate, forward +2 was fine.. but -2 for reverse wasn't - IIRC it just paused and didn't move the timeline backwards.
Did you try -1? Is your video encoded with B-frames?
I didn't try -1, it would be too slow and I assumed a negative playbackrate wouldn't work properly - the AVPro docs say it's generally not recommended to use anyway.
Unfortunately I've no idea if we have B-frames.
Unless this is a very bad way to do it for some reason, I've got something working for both platforms that I'm happy with.
public void SpeedSeek(bool forward)
{
if (_isSeeking) { return; }
#if UNITY_IOS
RegisterMediaPlayerEvents(true);
#endif
if (_mediaPlayer && _mediaPlayer.Control != null)
{
_isSeeking = true;
double sliderValue = forward ? 0.15 : -0.15;
TimeRanges bufferedRange = _mediaPlayer.Control.GetBufferedTimes();
double seekTo = _mediaPlayer.Control.GetCurrentTime() + sliderValue;
#if UNITY_EDITOR || UNITY_IOS
if (seekTo > bufferedRange.MinTime && seekTo < bufferedRange.MaxTime)
{
#if UNITY_EDITOR
sliderValue = forward ? 10 : -10;
#elif UNITY_IOS
sliderValue = forward ? 4 : -4;
#endif
seekTo = _mediaPlayer.Control.GetCurrentTime() + sliderValue;
}
#endif
double time = seekTo;
#if UNITY_ANDROID
_mediaPlayer.Control.SeekFast(time);
_isSeeking = false;
#elif UNITY_IOS
_mediaPlayer.Control.Seek(time);
#endif
}
}
on iOS _isSeeking is set to false with the media event
Yeah, it can be a bit tricky with HLS, so if its working for you then I'd stick with it.
Great, thanks for the help!
Platforms:
AVPro: v2.6.5
I'm adding additional video navigation into our VR videos. Skip forward/back 10 secs, and FF/ RR.
To define what I mean by FF/RR is: Hold the button and the video moves in that direction at an increased speed (like old VHS players used to).
I'm currently doing this, and it works great on Android.
However, on iOS I'm having trouble getting it to work the same.
I've tried using Seek(), SeekFast(), SeekWithTolerance().
Is what I'm trying to do possible? Or do I need to implement this some completely different way?