コード例 #1
0
        /// <summary> VideoPlayer 切换“VideoClip”后,第一次进行播放 </summary>
        public virtual void VideoPlayStart(UnityEngine.Video.VideoPlayer videoPlayer, UnityEngine.Video.VideoClip videoClip)
        {
            JudgeVideoPlayer(videoPlayer);

            videoPlayer.clip = videoClip;
            videoPlayer.Play();

            //动态切换 VideoClip 后,VideoPlayer 容易丢失 AudioSource,此举是动态赋予 AudioSource
            if (videoPlayer.GetComponent <AudioSource>() == null)
            {
                videoPlayer.gameObject.AddComponent <AudioSource>();
            }
            videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
            videoPlayer.SetTargetAudioSource(0, videoPlayer.GetComponent <AudioSource>());
        }
コード例 #2
0
        public override void SetClip(VideoInfo video)
        {
            var fileName = video.fileName;

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            if (!fileName.EndsWith(".mp4"))
            {
                fileName = fileName + ".mp4";
            }

            var url = "file://" + Application.streamingAssetsPath + "/" + fileName;

#if !UNITY_EDITOR && UNITY_ANDROID
            url = "jar:" + url;
#endif

            if (video.material != null)
            {
                videoPlayer.GetComponent <MeshRenderer>().material = video.material;
            }

            videoPlayer.url = url;
            videoPlayer.Prepare();
        }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        vbBtnObj = GameObject.Find("btn2");
        vbBtnObj.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);
        reviews.GetComponent <Animator>();
        video.GetComponent <Animator>();
        info.GetComponent <Animator>();

        vid.GetComponent <UnityEngine.Video.VideoPlayer>();
        //videoPlayer = GetComponent<UnityEngine.Video.VideoPlayer>();
        //var videoPlayer = gameObject.AddComponent<UnityEngine.Video.VideoPlayer>();
        //vid = gameObject.GetComponent("video quad") as VideoPlayer;
    }
コード例 #4
0
    void Update()
    {
        // プレイヤーが箱を持ち上げた時、2つ目の動画に切り替わる
        if (player != null && lf.IsLifting && tutorialVideo2 != null)
        {
            vp1.time = 0.0f;
            vp1.Pause();

            vp1.GetComponent <Image>().enabled = false;
            vp1.gameObject.SetActive(false);

            video = tutorialVideo2;
            vp    = vp2;

            if (vp.isPlaying)
            {
                vp.GetComponent <Image>().enabled = true;
            }
            vp.gameObject.SetActive(true);
            //vp.Play();
        }
        // 箱を下ろした時、1つ目の動画に切り替わる
        else
        {
            if (tutorialVideo2 != null)
            {
                vp2.time = 0.0f;
                vp2.Pause();

                vp2.GetComponent <Image>().enabled = false;
                vp2.gameObject.SetActive(false);
            }

            video = tutorialVideo1;
            vp    = vp1;

            if (vp.isPlaying)
            {
                vp.GetComponent <Image>().enabled = true;
            }

            vp.gameObject.SetActive(true);
            //vp.Play();
        }
    }