Trying to use the Gear VR touchpad as a play/pause input

Hi,

I’ve been trying for a while now with little luck to set up a pause/play in my project. The idea is that I have a texture playing a 360 video (this bit works fine). I have a Media Player Ctrl script that handles playback and playback states (paused, playing, etc).

I then wish to use a second script to handle the input functions using a tap on the Gear VR’s touchpad - which I am to understand counts as a ‘mouse 0’ type input. I’ve checked Fire1 uses mouse 0 as the positive button.

I’m not getting any errors on my script in Unity, but tapping the touchpad isn’t affecting playback at all :frowning:

I’m a bit out of my depth with C# right now as a newbie, but I’ve used the basis of another GUI script and I believe it’s connecting correctly with the media player Ctrl script.

Any thoughts or suggestions?

Thanks in advance,
Laurence

using UnityEngine;
using System.Collections;
using System;

namespace VRStandardAssets.Utils
{
    public class MedaiPlayerSampleGUI : MonoBehaviour
    {


        public MediaPlayerCtrl scrMedia;
        public VRInteractiveItem m_VRInteractiveItem;

        public bool m_bFinish = false;
        
        // Use this for initialization
        void Start()
        {
            scrMedia.OnEnd += OnEnd;

        }


        // Update is called once per frame
        void Update()
        {
            if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    scrMedia.Pause();
                }
            }
            if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    scrMedia.Play();
                }
            }
        }
        void OnEnd()
        {
            m_bFinish = true;
        }
    }
}

By Jove, I’ve got it!

The trick is not to bother using VRInput for this, just use the regular Input.GetMouseButtonDown method.

Touchpad counts as mouse 0, so if the script is written like so:

using UnityEngine;
using VRStandardAssets.Utils;

namespace VRStandardAssets.Examples
{
    public class VideoPausePlay : MonoBehaviour
    {
        [SerializeField] private MediaPlayerCtrl scrMedia;

        void Update()
        {
            if (Input.GetMouseButtonDown(0))
                if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
                    scrMedia.Pause();

                else if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED)
                    scrMedia.Play();
        }
    }
}

This will Pause when the video is playing, or Play when the video is paused. In the Editor you will need to drag the gameObject that contains the MediaPlayerCtrl script onto the corresponding “Scr Media” field so it knows which Video Manager to look to for player status.