How can I pause a video in one scene, go to another scene, and then return to the previous scene and resume from the place where the video was paused?
Hello,
I have created a script that allows me to record the time and frame number of the video when I exit the scene (when I press the button that takes me to the next scene). However, every time I try to go back to the previous scene, it does not resume from the frame at which it was paused, but it starts at the beginning again. Does anyone know how to achieve this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class videotime : MonoBehaviour
{
public double time;
private long frame;
VideoPlayer vidPlayer = null;
// Start is called before the first frame update
void Start()
{
vidPlayer = GetComponent<VideoPlayer>();
vidPlayer.Prepare();
time = 1d;
Debug.Log("vp " + vidPlayer);
}
public void TimeGrab(string choice) {
vidPlayer = GetComponent<VideoPlayer>();
if (choice == "pause")
{
frame = vidPlayer.frame;
//time = vidPlayer.time;
Debug.Log("frame " + frame);
vidPlayer.Pause() ;
}
else {
vidPlayer.frame = frame;
//vidPlayer.time = time;
Debug.Log("frame " + frame);
vidPlayer.Play(); }
Debug.Log("time " + time);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612194456im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Syncing Video and Game Object Audio 0 Answers
Play video seconds(frames) problem 1 Answer
Reset current game frame 0 Answers
device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) In OnTriggerStay() 1 Answer
Helper Lines Do Not Seem ! 0 Answers