(Drag the blank image to the Blank variable in inspector)
This forces the target texture to the alpha texture (i.e nothing) and then when you call videoPlayer.Play() the next frame to be written to the target texture is the first frame of the video (which is the desired result).
Every time you load the scene the video player game object will blank the last frame with the alpha texture.
Word of warning unity will use a screen shot of the game view for the texture if you forget to drag the blank image in.
Again this is what worked for me, I hope it helps.
targetTexture.Release() works in PrepareVideo method in VideoPlayerController script that is subbed to VideoPlayer:
IEnumerator PrepareVideo()
{
yield return new WaitForEndOfFrame();
_videoPlayer.Prepare();
_videoPlayer.targetTexture.Release(); //remove last frame of previously played video
}
Not sure why this method works, but the last frame gets removed and its not played the second time I play the video. Don’t forget to add StartCoroutine(PrepareVideo()) in SetVideo method
This might be late, but I think I have found a solution to the problem!
I added the rendered texture of the video player onto a raw image so that I can display the video on the raw image. After that all you have to do is just simply set the “enable” property to false on the raw image when the video player is at frame 0, and then change it to true when the frame has passed 0. Like this:
using UnityEngine.Video;
using UnityEngine.UI;
public RawImage videoDisplay;
public VideoPlayer videoPlayer;
private void Update()
{
if (videoPlayer.frame < 0)
{
videoDisplay.enabled = false;
}
else if (videoPlayer.frame > 0)
{
videoDisplay.enabled = true;
}
}