Search Unity

How to start playback on a frame other than 0, using GvrVideoPlayerTexture

Discussion in 'Daydream' started by HeyBishop, Mar 24, 2018.

  1. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    Perhaps I should ask in this forum too...

    I'm trying to get GvrVideoPlayerTexture to start playing a video at a frame other than frame 0. I figure using
    .CurrentPosition
    would do the trick - but it doesn't.

    This is the code I'm using to start the video playing, and for it to loop back to the beginning. But for the life of me, I can't get it to start playing anywhere other than at the very beginning.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class MyPlayVideo : MonoBehaviour {
    4.     private float t;
    5.     private GvrVideoPlayerTexture player;
    6.  
    7.     public float delay = 2f;
    8.     public long startFrame;
    9.  
    10.     void Start() {
    11.         t = 0;
    12.         player = GetComponent<GvrVideoPlayerTexture>();
    13.         player.Init();
    14.         player.Pause ();
    15.         player.CurrentPosition = startFrame;  // I've also tried this code in update
    16.     }
    17.  
    18.     void Update() {
    19.         if (player.PlayerState == GvrVideoPlayerTexture.VideoPlayerState.Ended)
    20.         {
    21.             player.Pause ();
    22.             player.CurrentPosition = 0;
    23.             t = 0f;
    24.             return;
    25.         }
    26.        
    27.       t += Time.deltaTime;
    28.       if (t >= delay)
    29.         {
    30. //        player.CurrentPosition = startFrame;  // it doesn't work here
    31.             player.Play ();
    32. //        player.CurrentPosition = startFrame;  // or here
    33.           }
    34.     }
    35. }
    This code successfully gets the video to play, after a delay. But it always starts on frame 0.

    I'm just about to give up on Daydream. If this isn't possible, I might have to consider a different platform/device.
     
  2. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238