GetDuration() public method

public GetDuration ( ) : int
return int
示例#1
0
    //获取视频总时间
    string GetTatalTime()
    {
        int    time      = m_srcVideo.GetDuration();
        int    durationM = time / 1000 / 60;
        int    durationS = time / 1000 % 60;
        string durM      = durationM < 10 ? "0" + durationM : durationM + "";
        string durS      = durationS < 10 ? "0" + durationS : durationS + "";
        string total     = durM + ":" + durS;

        return(total);
    }
    // Update is called once per frame
    void Update()
    {
        if (bigThumb.GetComponent <ThumbnailScript>().timeManipulation == ThumbnailScript.TimeManipulation.TimelineGazeThumbnail)
        {
            ThumbnailScript thumbnailScript = GameObject.Find("BigThumb").GetComponent <ThumbnailScript>();

            if (thumbnailScript.tutorialPhase1 || thumbnailScript.tutorialPhase2)
            {
                if (!thumbnailScript.tlgazetut)
                {
                    forwardThumb.SeekTo(0);
                    GameObject.Find("tlgaze_tut").GetComponent <MeshRenderer>().enabled = true;
                    thumbnailScript.tlgazetut = true;
                }
            }

            RaycastHit hit;

            if (Time.frameCount % 3 == 0 && Physics.Raycast(GameObject.Find("Camera").transform.position, GameObject.Find("Camera").transform.position + GameObject.Find("Camera").transform.forward * 0.1f, out hit, Mathf.Infinity, 1 << 9))
            {
                if (hit.collider.gameObject.name == "ThumbTimeline")
                {
                    if ((thumbnailScript.tutorialPhase1 || thumbnailScript.tutorialPhase2) && thumbnailScript.tlgazetut)
                    {
                        thumbnailScript.tlgazetutdone = true;
                        GameObject.Find("OK").GetComponent <MeshRenderer>().enabled         = true;
                        GameObject.Find("tlgaze_tut").GetComponent <MeshRenderer>().enabled = false;

                        if (thumbnailScript.timeManipulation == thumbnailScript.techniqueOrder[0] || thumbnailScript.timeManipulation == thumbnailScript.techniqueOrder[2])
                        {
                            GameObject.Find("TaskText").GetComponent <TextMeshPro>().text = "First part of the tutorial complete!\n\nGaze at the \"OK\" button above to continue to the second part.";
                        }
                        else
                        {
                            GameObject.Find("TaskText").GetComponent <TextMeshPro>().text = "Second part of the tutorial complete!\n\nGaze at the \"OK\" button above when you are ready to proceed with the experiment.";
                        }
                    }

                    Vector3 thumbPosition = GameObject.Find("ThumbTimeline").transform.position;
                    float   playbackTime  = Mathf.Min(2.5f, Vector3.Distance(new Vector3(thumbPosition.x, 0, thumbPosition.z) - GameObject.Find("ThumbTimeline").transform.right * 1.25f, new Vector3(hit.point.x, 0, hit.point.z))) / 2.5f;

                    if (playbackTime < 0.25f && Vector3.Distance(new Vector3(thumbPosition.x, 0, thumbPosition.z), new Vector3(hit.point.x, 0, hit.point.z)) > 1.25f)
                    {
                        playbackTime = 0;
                    }

                    forwardThumb.SeekTo((int)(playbackTime * forwardThumb.GetDuration()));
                    backThumb.SeekTo((int)(playbackTime * forwardThumb.GetDuration()));
                    forwardScene.SeekTo((int)(playbackTime * forwardThumb.GetDuration()));
                    backScene.SeekTo((int)(playbackTime * forwardThumb.GetDuration()));
                }
            }
        }
    }
示例#3
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(50, 50, 100, 100), "Load"))
        {
            scrMedia.Load("EasyMovieTexture.mp4");
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(50, 200, 100, 100), "Play"))
        {
            scrMedia.Play();
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(50, 350, 100, 100), "stop"))
        {
            scrMedia.Stop();
        }

        if (GUI.Button(new Rect(50, 500, 100, 100), "pause"))
        {
            scrMedia.Pause();
        }

        if (GUI.Button(new Rect(50, 650, 100, 100), "Unload"))
        {
            scrMedia.UnLoad();
        }

        if (GUI.Button(new Rect(50, 800, 100, 100), " " + m_bFinish))
        {
        }

        if (GUI.Button(new Rect(200, 50, 100, 100), "SeekTo"))
        {
            scrMedia.SeekTo(10000);
        }


        if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
        {
            if (GUI.Button(new Rect(200, 200, 100, 100), scrMedia.GetSeekPosition().ToString()))
            {
            }

            if (GUI.Button(new Rect(200, 350, 100, 100), scrMedia.GetDuration().ToString()))
            {
            }
        }
    }
示例#4
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     //This sends your data to the other players in the same room
     if (stream.isWriting)
     {
         stream.SendNext(PhotonNetwork.playerName.ToString());
         //Debug.Log(PhotonNetwork.playerName.ToString());
         stream.SendNext(srcMedia.GetSeekPosition());
         //Debug.Log(srcMedia.GetSeekPosition());
         stream.SendNext(srcMedia.GetDuration());
         //Debug.Log(srcMedia.GetDuration());
         stream.SendNext(srcMedia.current_video);
         //Debug.Log(srcMedia.current_video);
     }
     //This recieves information from other players in the same room
     else
     {
         int    a = (int)stream.ReceiveNext();
         int    b = (int)stream.ReceiveNext();
         string c = (string)stream.ReceiveNext();
     }
 }
    // Update is called once per frame
    void Update()
    {
        lightSwitch.isOn = isOn;
        if (backgroundPlayer.GetCurrentState() != MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
        {
            return;
        }

        if (!isRendered && backgroundPlayer.GetSeekPosition() > 1000)
        {
            GameObject.Find("Theater").transform.localScale = new Vector3(30, 30, 30);
            isRendered = true;
            backgroundPlayer.Pause();
            backgroundPlayer.SeekTo(0);
            GameObject.Find("Music").GetComponent <AudioSource> ().Play();
        }

        if (isOn)
        {
            int currentPosition = backgroundPlayer.GetSeekPosition();
            Debug.Log("lightSwitch position: " + currentPosition);
            if (currentPosition + 100 >= backgroundPlayer.GetDuration())
            {
                backgroundPlayer.Pause();
            }
        }
        else
        {
            int currentPosition = backgroundPlayer.GetSeekPosition();
            Debug.Log("lightSwitch position: " + currentPosition);
            if (currentPosition >= lightOffEndSeekPosition)
            {
                backgroundPlayer.Pause();
            }
        }
    }
示例#6
0
    void Update()
    {
        if (scrMedia.m_strFileName.Equals("LoginVideo.mp4") && scrMedia.GetSeekPosition() >= scrMedia.GetDuration() - 1000)
        {
            scrMedia.SeekTo(3500);
        }

        if (scrMedia.m_strFileName.Equals("ContinueVideo.mp4") && scrMedia.GetSeekPosition() >= scrMedia.GetDuration() - 1000)
        {
            scrMedia.SeekTo(1200);
        }

        if (scrMedia.m_strFileName.Equals("cardboard.mp4") && scrMedia.GetSeekPosition() >= scrMedia.GetDuration() - 500)
        {
            scrMedia.SeekTo(1500);
        }
    }
    void OnGUI()
    {
        if (GUI.Button(new Rect(50, 50, 100, 100), "Load"))
        {
            scrMedia.Load("Long_teaser_HQ.mp4");
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(50, 200, 100, 100), "Play"))
        {
            scrMedia.Play();
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(50, 350, 100, 100), "stop"))
        {
            scrMedia.Stop();
        }

        if (GUI.Button(new Rect(50, 500, 100, 100), "pause"))
        {
            scrMedia.Pause();
        }

        if (GUI.Button(new Rect(50, 650, 100, 100), "Unload"))
        {
            scrMedia.UnLoad();
        }

        if (GUI.Button(new Rect(50, 800, 100, 100), " " + m_bFinish))
        {
        }

        if (GUI.Button(new Rect(200, 50, 100, 100), "SeekTo"))
        {
            scrMedia.SeekTo(10000);
        }


        if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
        {
            if (GUI.Button(new Rect(200, 200, 100, 100), scrMedia.GetSeekPosition().ToString()))
            {
            }

            if (GUI.Button(new Rect(200, 350, 100, 100), scrMedia.GetDuration().ToString()))
            {
            }

            if (GUI.Button(new Rect(200, 450, 100, 100), scrMedia.GetVideoWidth().ToString()))
            {
            }

            if (GUI.Button(new Rect(200, 550, 100, 100), scrMedia.GetVideoHeight().ToString()))
            {
            }
        }

        if (GUI.Button(new Rect(200, 650, 100, 100), scrMedia.GetCurrentSeekPercent().ToString()))
        {
        }
    }
 // Use this for initialization
 void Start()
 {
     controller           = GetComponent <MediaPlayerCtrl>();
     currentVideoDuration = controller.GetDuration();
     videoIndex           = 0;
 }
    void OnGUI()
    {
        if (GUI.Button(new Rect(7 * (Screen.width / spaceBtnW), (Screen.height / spaceBtnH), btnWidth, btnHeight), "Reset"))
        {
            currentVideoIndex = 0;
            scrMedia.Load("" + strVideoName[currentVideoIndex]);
            m_bFinish = false;
        }

        if (GUI.Button(new Rect(7 * (Screen.width / spaceBtnW), 4 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Next"))
        {
            if (currentVideoIndex != strVideoName.Length - 1)
            {
                currentVideoIndex += 1;
                scrMedia.Load("" + strVideoName[currentVideoIndex]);
                m_bFinish = false;
            }
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), (Screen.height / spaceBtnH), btnWidth, btnHeight), "Load"))
        {
            scrMedia.Load("" + strVideoName[currentVideoIndex]);
            m_bFinish = false;
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 4 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Play"))
        {
            scrMedia.Play();
            m_bFinish = false;
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 7 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Stop"))
        {
            scrMedia.Stop();
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 10 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Pause"))
        {
            scrMedia.Pause();
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 13 * (Screen.height / spaceBtnH), btnWidth, btnHeight), "Unload"))
        {
            scrMedia.UnLoad();
        }

        if (GUI.Button(new Rect((Screen.width / spaceBtnW), 16 * (Screen.height / spaceBtnH), btnWidth, btnHeight), " " + m_bFinish))
        {
        }

        if (GUI.Button(new Rect(4 * (Screen.width / spaceBtnW), (Screen.height / spaceBtnH), btnWidth, btnHeight), "SeekTo"))
        {
            scrMedia.SeekTo(10000);
        }


        if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
        {
            if (GUI.Button(new Rect(4 * (Screen.width / spaceBtnW), 4 * (Screen.height / spaceBtnH), btnWidth, btnHeight), scrMedia.GetSeekPosition().ToString()))
            {
            }

            if (GUI.Button(new Rect(4 * (Screen.width / spaceBtnW), 7 * (Screen.height / spaceBtnH), btnWidth, btnHeight), scrMedia.GetDuration().ToString()))
            {
            }
        }
    }
 public override int GetLength()
 {
     return(player.GetDuration());
 }