Search Unity

VR videoplayer

Discussion in 'AR/VR (XR) Discussion' started by Kjelle69, Dec 9, 2018.

  1. Kjelle69

    Kjelle69

    Joined:
    Nov 9, 2016
    Posts:
    53
    Is there an easy way to play a 360 video in a VR-headset and be able to adjust the speed of the video. I was thinking of making a throttle input for some kind of 360 video in a vehicle? :)
     
  2. Kjelle69

    Kjelle69

    Joined:
    Nov 9, 2016
    Posts:
    53
  3. Kjelle69

    Kjelle69

    Joined:
    Nov 9, 2016
    Posts:
    53
    Talking to myself here but it was easier than I thought to do this.
    I can now control the playbackspeed and watch a 360 video in the Oculus. Sweet :D

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Video;
    5. using UnityEngine.UI;
    6.  
    7.  
    8.  
    9. public class VideoControl : MonoBehaviour {
    10. private VideoPlayer videoPlayer;
    11. public float Vspeed = 1.0f;
    12.     // Use this for initialization
    13.     void Start () {
    14.        
    15.  
    16.         videoPlayer = GetComponent<VideoPlayer>();
    17.  
    18.     }
    19.    
    20.     // Update is called once per frame
    21.     void Update () {
    22.         if (Input.GetKey("up"))
    23.         {
    24.             Vspeed += 0.1f;
    25.         }
    26.  
    27.         if (Input.GetKey("down"))
    28.         {
    29.             Vspeed -= 0.1f;
    30.         }
    31.         print("Speed="+Vspeed);
    32.  
    33.  
    34.  
    35.  
    36.         videoPlayer.playbackSpeed = Vspeed;
    37.  
    38.     }
    39. }
    40.  
     
    JoeStrout likes this.