VideoPlayer black frames between clips.
I am attempting to switch between a series of mp4 movies with a simple 2D interface. I am running into an issue that I hope I can work around to. When switching video clips, I get several black frames.
I have tried several switching methods (camera switch, scene switch, video player switch and clip array swaps) for jumping to different content in the cameras far plane. Pausing the clip does not seem to help. On a switch, I am getting black frames.
I understand I have to wait for the next movie to load, the content is built for a delay. Is there a way to avoid the player going to black during the transition? Can I capture the far plane and display the last good frame in the near plane during the transition? Is my method incorrect?
The following script is the structure I would prefer to use if I can find a solution to the black frames, I have simplified it to include only the video setup:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
[RequireComponent(typeof(VideoPlayer))]
public class stageTools_clean : MonoBehaviour {
public VideoClip[] vids;
private VideoPlayer vp;
private int ii = 0;
// Use this for initialization
void Start () {
vp = gameObject.GetComponent<VideoPlayer>();
vp.clip = vids[0];
}
public void PlayVideo(int id)
{
if (id<0 || id >= vids.Length)
{
id = 0;
ii = 0;
}
vp.Pause();
vp.clip = vids[id];
vp.Play();
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0))
{
++ii;
PlayVideo(ii);
}
}
}
Thanks in advance for your help...
Same here. I'm considering having two VideoPlayer and one pausing before the next clip is ready in the second VideoPlayer ...