Hello,
I think I found an issue with some versions of Unity and the VideoPlayer component.
I made a script to manually update the VideoPlayer frames so I can change the speed of the video given certain parameters. Example:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class VideoTest : MonoBehaviour
{
public VideoPlayer player;
public float speed = 1f;
float percent = 0f;
long frame = 0;
void Start()
{
player.playOnAwake = false;
player.isLooping = false;
player.renderMode = VideoRenderMode.RenderTexture;
player.audioOutputMode = VideoAudioOutputMode.None;
player.frame = 1;
player.Play();
}
// Update is called once per frame
void Update()
{
percent += Time.deltaTime * speed;
if (percent > 1f)
{
frame++;
percent = 0f;
}
player.frame = frame;
player.Play();
}
}
This works just fine in Unity 2019.4.16f1, but in newer versions (2019.4.40f1, 2020.3.15f1, 2021.3.9f1) the video does not changes the frame.
I found this bug report that looks like this very same problem, but it’s marked as a duplicate of another bug that seems to be something related to video width and height.
Is this in fact a Unity bug or were there changes in the way we should work with VidePlayer in newer versions?
Thanks!