Example #1
0
    private void NextVideo()
    {
        if (!singleVideoMode)
        {
            videoIndex++;
            if (videoIndex > videoList.Length - 1)
            {
                videoIndex = 0;
            }

            if (currentPlayer.GetInstanceID() == player1.GetInstanceID())
            {
                currentPlayer = player2;
                queuedPlayer  = player1;
            }
            else
            {
                currentPlayer = player1;
                queuedPlayer  = player2;
            }

            queuedPlayer.url = videoList[videoIndex];
            queuedPlayer.Prepare();
            queuedPlayer.frame = 1;
            Debug.Log("VideoIndex = " + videoIndex);
        }
    }
    // Initializes the video renderer and other GUI elements.
    void Start()
    {
        RenderTexture rendTex =
            new RenderTexture(VID_WIDTH, VID_HEIGHT, VID_CDEPTH);

        if (!videoPlayer.clip)
        {
            Debug.LogError(videoPlayer.name + " " + videoPlayer.GetInstanceID() + " has no video clip.");
            this.enabled = false;
            return;
        }

        videoRenderer.texture     = rendTex;
        videoPlayer.targetTexture = rendTex;

        videoPlayer.Prepare();
        videoPlayer.StepForward();

        timeText.text =
            FormatTime((int)videoPlayer.time) + " / " + FormatTime((int)videoPlayer.clip.length);
    }