SeekTo() public method

public SeekTo ( int iSeek ) : void
iSeek int
return void
Exemplo n.º 1
0
    // 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();
            }
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// Seek to specific time of video.
        /// </summary>
        /// <param name="seekTime">Seek time.</param>
        public void SeekTo(float seekTime)
        {
            if (CurrentState != StateType.Started)
            {
                return;
            }
#if USE_EASY_MOVIE_TEXTURE
            if (easyMovieTexture == null)
            {
                return;
            }
            easyMovieTexture.SeekTo((int)seekTime);
#elif USE_UNITY_VIDEO_PLAYER
            if (videoPlayer == null)
            {
                return;
            }
            long seekFrames = (long)(seekTime * videoPlayer.frameRate);
            videoPlayer.frame = seekFrames;
#elif USE_ANDROID_MEDIA_PLAYER
            if (mediaPlayer == null)
            {
                return;
            }
            try
            {
                mediaPlayer.Call("seekTo", (int)(seekTime * 1000));
                //mediaPlayer.Call("seekTo", new object[] { (long)(seekTime * 1000), 0 });
            }
            catch (Exception e)
            {
                Debug.LogError(TAG + " Failed to seek mediaPlayer: " + e.Message);
                UpdateState(StateType.Error);
            }
#elif USE_VIVE_MEDIA_DECODER
            if (mediaDecoder == null)
            {
                return;
            }
            mediaDecoder.setSeekTime(seekTime);
#else
            Debug.Log(TAG + " SeekTo function not supported for Unity Movie Texture");
#endif
        }
Exemplo n.º 3
0
 public void Seek(float seconds)
 {
     controls.SeekTo((int)(seconds * 1000f));
 }
Exemplo n.º 4
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()))
            {
                scrMedia.SetSpeed(2.0f);
            }

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

            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()))
        {
        }
    }
Exemplo n.º 5
0
 public void ChangePlaybackPosition(float pos)
 {
     controller.SeekTo(Mathf.FloorToInt(pos * currentVideoDuration));
 }
    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()))
            {
            }
        }
    }
Exemplo n.º 7
0
 // note: make sure to have them ready beforehand.
 public static void SynchronizeWith(this MediaPlayerCtrl self, MediaPlayerCtrl target)
 {
     self.SeekTo(target.GetSeekPosition());
 }
Exemplo n.º 8
0
 // in second format.
 public static void SeekToTime(this MediaPlayerCtrl self, float time)
 {
     self.SeekTo((int)time * 1000);
 }
 public override void SetPosition(int ms)
 {
     player.SeekTo(ms);
 }
Exemplo n.º 10
0
 void GetTotal()
 {
     Debug.Log("SeekTo");
     m_srcVideo.SeekTo(1);
     // Debug.Log("GetDuration:" + m_srcVideo.SeekTo(0));
 }