Ejemplo n.º 1
0
    public void PlayVideo(VideoClip clip)
    {
        lastClip              = clip;
        videoAudio.loop       = false;
        videoPlayer.isLooping = false;

        StopAllCoroutines();

        if (!isTapeSet)
        {
            videoPlayer.clip = clip;
            lastFrame        = 0;
            hasInput         = true;
            hasTape          = true;
            isRender         = true;
            isStarted        = true;
            isTapeSet        = true;
        }

        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer.SetTargetAudioSource(0, videoAudio);
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.controlledAudioTrackCount = 1;
        videoPlayer.targetTexture             = renderTexture;

        if (isOn)
        {
            Display.material = RenderMaterial;
            Display.material.SetTexture("_MainTex", renderTexture);
        }

        StartCoroutine(PrepareAndPlay(lastFrame));
    }
Ejemplo n.º 2
0
    public void Play(UnityEngine.Video.VideoClip videoClip)
    {
        //  videoPlayer.Stop();

        RenderTexture.active = videoPlayer.targetTexture;
        GL.Clear(false, true, new Color(0.0f, 0.0f, 1.0f, 1.00f));
        GL.Color(new Color(0.0f, 0.0f, 1.0f, 1.0f));
        RenderTexture.active = null;

        videoPlayer.source = VideoSource.VideoClip;

        videoPlayer.clip = videoClip;

        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        Debug.Log("videoClip.audioTrackCount= " + videoClip.audioTrackCount);
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);
        videoPlayer.prepareCompleted += (source) =>
        {
            source.Play();
            audioSource.Play();
        };

        videoPlayer.loopPointReached += (source) =>
        {
            EventMgr.startEvent("关闭");
        };

        videoPlayer.Prepare();
    }
Ejemplo n.º 3
0
    private IEnumerator CoPlayMovieFromVideoClip(VideoClip clip, Action onEnded)
    {
        onEndMovie = onEnded;

        videoPlayer.source = VideoSource.VideoClip;
        videoPlayer.url    = null;

        //Set Audio Output to AudioSource
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

        //Assign the Audio from Video to AudioSource to be played
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);

        //Set video To Play then prepare Audio to prevent Buffering
        videoPlayer.clip = videoClipToPlay;
        videoPlayer.Prepare();

        //Wait until video is prepared
        WaitForSeconds waitTime = new WaitForSeconds(1);

        while (!videoPlayer.isPrepared)
        {
            //Prepare/Wait for 5 sceonds only
            yield return(waitTime);

            //Break out of the while loop after 5 seconds wait
            break;
        }
        Debug.Log("Done Preparing Video");

        videoPlayer.controlledAudioTrackCount = videoPlayer.audioTrackCount;

        //Play Video
        videoPlayer.Play();

        //Play Sound
        audioSource.Play();

        while (videoPlayer.texture == null)
        {
            yield return(null);
        }
        Debug.Log("Done Prepared display texture");

        //Assign the Texture from Video to RawImage to be displayed
        targetImage.texture = videoPlayer.texture;

        Debug.Log("Playing Video");

        while (videoPlayer.isPlaying)
        {
            yield return(null);
        }

        Debug.Log("Done Playing Video");

        VideoPlayer_endMovie();
    }
Ejemplo n.º 4
0
    IEnumerator playVideo()
    {
        //Add VideoPlayer to the GameObject
        videoPlayer = gameObject.AddComponent <VideoPlayer>();

        //Add AudioSource
        audioSource = gameObject.AddComponent <AudioSource>();

        //Disable Play on Awake for both Video and Audio
        videoPlayer.playOnAwake = false;
        audioSource.playOnAwake = false;
        audioSource.Pause();

        //We want to play from video clip not from url

        videoPlayer.source = VideoSource.VideoClip;

        // Vide clip from Url
        //videoPlayer.source = VideoSource.Url;
        //videoPlayer.url = "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4";


        //Set Audio Output to AudioSource
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

        //Assign the Audio from Video to AudioSource to be played
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);

        //Set video To Play then prepare Audio to prevent Buffering
        videoPlayer.clip = videoToPlay;
        videoPlayer.Prepare();

        //Wait until video is prepared
        while (!videoPlayer.isPrepared)
        {
            yield return(null);
        }

        Debug.Log("Done Preparing Video");

        //Assign the Texture from Video to RawImage to be displayed
        image.texture = videoPlayer.texture;

        //Play Video
        videoPlayer.Play();

        //Play Sound
        audioSource.Play();

        Debug.Log("Playing Video");
        while (videoPlayer.isPlaying)
        {
            Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)videoPlayer.time));
            yield return(null);
        }
        image.enabled = false;

        Debug.Log("Done Playing Video");
    }
Ejemplo n.º 5
0
    /// <summary>
    ///  Subir video
    /// </summary>
    /// <param name="ruta"></param>
    /// <returns>Video y audio en el componente Video Player</returns>
    IEnumerator video(string ruta)
    {
        WWW www = new WWW("file:///" + ruta);

        yield return(www);

        Debug.Log(www.url);

        movie                           = plane.GetComponent <VideoPlayer>();
        movie.url                       = (www.url).Replace("file:///", "");
        movie.audioOutputMode           = VideoAudioOutputMode.AudioSource;
        movie.controlledAudioTrackCount = 1;
        movie.EnableAudioTrack(0, true);
        movie.SetTargetAudioSource(0, plane.GetComponent <AudioSource>());
        movie.Play();
        //movie.Pause();
        // Destruye cualquier elemento hijo del contenedor de modelos 3d
        if (objeto.transform.childCount >= 1)
        {
            Transform c = objeto.transform.GetChild(0);
            c.parent = c;
            Destroy(c.gameObject);
        }
        plane.SetActive(true);
        plane.GetComponent <MeshRenderer>().enabled = true;
        plane.transform.localPosition = new Vector3(0, 0, 0);
        plane.transform.localScale    = new Vector3(0.07f, 0.07f, 0.07f);
        plane.transform.localRotation = Quaternion.Euler(90, -90, 90);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Prepares a video file for playback by loading it in the video player + initializing audio.
    /// If the file, does not exist, it is downloaded from Azure blob storage first, using default override settings.
    /// All files are downloaded to the TempCache app folder, and played from there.
    /// </summary>
    /// <param name="videofile">The file name (no path) of the video to be played.</param>
    public async Task PrepareVideoFromFile(string videofile)
    {
        string localvideofile = await AzureBlobStorageClient.instance.DownloadStorageBlockBlobSegmentedOperationAsync(videofile);

        if (File.Exists(localvideofile))
        {
            if (videoPlayer.isPlaying)
            {
                videoPlayer.Stop();
                playButtonImage.sprite = playImage;
            }
            videoPlayer.url             = localvideofile;
            videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
            videoPlayer.EnableAudioTrack(0, true);
            videoPlayer.SetTargetAudioSource(0, audioSource);

            SetTotalTimeUI(true);

            // Preparation is not needed for videos loaded from url
            //videoPlayer.Prepare();
            ////Wait until video is prepared
            //while (!videoPlayer.isPrepared)
            //{
            //    Debug.Log("Preparing Video");
            //    yield return null;
            //}
            //Debug.Log("Done Preparing Video");
        }
    }
Ejemplo n.º 7
0
 private void reconfigureAudio()
 {
     videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
     videoPlayer.EnableAudioTrack(0, true);
     videoPlayer.controlledAudioTrackCount = 1;
     videoPlayer.SetTargetAudioSource(0, vAudio);
 }
Ejemplo n.º 8
0
        private IEnumerator Co_PlayView()
        {
            _videoPlayer.playOnAwake = false;
            _audioSource.playOnAwake = false;
            _audioSource.Pause();

            _videoPlayer.source          = VideoSource.VideoClip;
            _videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

            _videoPlayer.EnableAudioTrack(0, true);
            _videoPlayer.SetTargetAudioSource(0, _audioSource);

            _videoPlayer.clip = _videoClip;
            _videoPlayer.Prepare();

            var waitTime = new WaitForSeconds(.5f);

            while (!_videoPlayer.isPrepared)
            {
                yield return(waitTime);

                break;
            }

            _image.texture = _videoPlayer.texture;

            _videoPlayer.Play();
            _audioSource.Play();

            while (_videoPlayer.isPlaying)
            {
                yield return(null);
            }
        }
Ejemplo n.º 9
0
        public override void Play(string url)
        {
            m_paused = false;

            m_logger.Debug("Play url={0}", url);

            if (url != null)
            {
                var localUrl = WebServices.Instance.MediaDownloadManager.GetPathForItem(url);

                m_videoPlayer.url = localUrl;

                m_videoPlayer.controlledAudioTrackCount = 1;
                //Assign the Audio from Video to AudioSource to be played
                m_videoPlayer.EnableAudioTrack(0, true);
                m_videoPlayer.SetTargetAudioSource(0, AudioSource);

                m_logger.Debug("Play - isPrepared={0}", m_videoPlayer.isPrepared);

                if (m_videoPlayer.isPrepared)
                {
                    m_videoPlayer.Play();
                }
                else
                {
                    m_playOnPrepare = true;

                    m_videoPlayer.Prepare();
                }
            }
        }
Ejemplo n.º 10
0
    public void PlayBuildVideo1()
    {
        GameObject cam = GameObject.Find("BuilderCamera");

        if (vid == null)
        {
            vid = transform.Find("vid").GetComponent <VideoPlayer>();
        }
        vid.enabled      = true;
        vid.targetCamera = cam.GetComponent <Camera>();
        transform.Find("pnlVid").gameObject.SetActive(true);
        Transform canv = transform.parent;

        transform.Find("pnlTutor").gameObject.SetActive(false);
        canv.Find("DPad(Clone)").gameObject.SetActive(false);
        canv.Find("ToolboxPanel").gameObject.SetActive(false);
        canv.Find("RoadPanel").gameObject.SetActive(false);
        canv.Find("MenuToggle").gameObject.SetActive(false);
        canv.Find("DeleteButton").gameObject.SetActive(false);


        vid.EnableAudioTrack(0, false);
        vid.source = VideoSource.VideoClip;

        StartCoroutine(playVideo());
    }
Ejemplo n.º 11
0
    private void Awake()
    {
        videoStarted   = false;
        videoComponent = gameObject.AddComponent <VideoPlayer>();
        audioComponent = gameObject.AddComponent <AudioSource>();

        videoComponent.playOnAwake = false;
        audioComponent.playOnAwake = false;

        videoComponent.source                    = VideoSource.VideoClip;
        videoComponent.clip                      = videoSource;
        videoComponent.isLooping                 = loop;
        videoComponent.targetTexture             = videoTexture;
        videoComponent.audioOutputMode           = VideoAudioOutputMode.AudioSource;
        videoComponent.controlledAudioTrackCount = 1;

        //audioComponent.clip = (AudioClip)AssetDatabase.LoadAssetAtPath("Assets/SeedQuestPrototype/Sounds/empty.mp3", typeof(AudioClip));
        audioComponent.loop         = loop;
        audioComponent.volume       = volume;
        audioComponent.spatialBlend = 1;
        audioComponent.rolloffMode  = AudioRolloffMode.Logarithmic;
        audioComponent.minDistance  = minDistance;
        audioComponent.maxDistance  = maxDistance;

        videoComponent.EnableAudioTrack(0, true);
        videoComponent.SetTargetAudioSource(0, audioComponent);
    }
    public IEnumerator PlayVideo(string url)
    {
        videoPlayer = gameObject.GetComponent <VideoPlayer>();
        audioSource = gameObject.GetComponent <AudioSource>();

        videoPlayer.playOnAwake = true;
        audioSource.playOnAwake = true;

        videoPlayer.source = VideoSource.Url;
        videoPlayer.url    = url;

        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);

        videoPlayer.Prepare();

        while (!videoPlayer.isPrepared)
        {
            Debug.Log("Preparing Video");
            yield return(null);
        }

        videoPlayer.Play();
        audioSource.Play();
    }
    private IEnumerator PrepareCoroutine()
    {
        if (renderTexture != null)
        {
            videoPlayer.renderMode = VideoRenderMode.RenderTexture;
        }

        videoPlayer.source          = VideoSource.VideoClip;
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);
        videoPlayer.Prepare();

        while (!videoPlayer.isPrepared)
        {
            yield return(null);
        }

        rawImage.texture = videoPlayer.texture;
        if (renderTexture != null)
        {
            videoPlayer.targetTexture = renderTexture;
        }

        StartCoroutine(PlayCoroutine());
    }
Ejemplo n.º 14
0
 void Start()
 {
     audioSource = GetComponent <AudioSource>();
     vPlayer.SetTargetAudioSource(0, audioSource);
     vPlayer.EnableAudioTrack(0, true);
     vPlayer.controlledAudioTrackCount = 1;
 }
    private IEnumerator StartVideo_Coroutine()
    {
        m_VideoPlayer.EnableAudioTrack(0, true);
        m_VideoPlayer.SetTargetAudioSource(0, GetComponent <AudioSource>());

        m_VideoPlayer.Prepare();

        while (!m_VideoPlayer.isPrepared)
        {
            yield return(null);
        }

        m_RawImage.texture = m_VideoPlayer.texture;

        m_VideoPlayer.Play();

        GetComponent <AudioSource>().Play();

        while (m_VideoPlayer.isPlaying)
        {
            print("Video isPlaying");
            yield return(null);
        }

        print("Done Playing Video");
    }
Ejemplo n.º 16
0
    IEnumerator playVideo()
    {
        //Assign the Audio from Video to AudioSource to be played
        videoPlayer.EnableAudioTrack(0, true);

        //Set video To Play then prepare Audio to prevent Buffering
        videoPlayer.clip = videoToPlay;
        videoPlayer.Prepare();

        //Wait until video is prepared
        while (!videoPlayer.isPrepared)
        {
            yield return(null);
        }


        //Play Video
        videoPlayer.Play();

        //Play Sound
        //audioSource.Play();


        while (videoPlayer.isPlaying)
        {
            yield return(null);
        }
    }
Ejemplo n.º 17
0
    private IEnumerator PlayVideo(Action callback = null)
    {
        _videoPlayer.playOnAwake     = false;
        _videoPlayer.isLooping       = true;
        _audioSource.playOnAwake     = false;
        _audioSource.loop            = false;
        _audioSource.volume          = 0.5f;
        _videoPlayer.source          = VideoSource.VideoClip;
        _videoPlayer.audioOutputMode = VideoAudioOutputMode.None;

        _videoPlayer.EnableAudioTrack(0, true);
        _videoPlayer.SetTargetAudioSource(0, _audioSource);

        _videoPlayer.clip = _movie;
        _videoPlayer.Prepare();

        while (!_videoPlayer.isPrepared)
        {
            yield return(null);
        }

        _texture.texture = _videoPlayer.texture;

        _videoPlayer.Play();
        _audioSource.Play();
        ScreenEffect.instance.ScreenFadeEffect(ScreenEffect.ScreenEffectType.Screen, Color.black, true);
        while (_videoPlayer.isPlaying)
        {
            yield return(null);
        }
        callback?.Invoke();
    }
Ejemplo n.º 18
0
        private void InitAudioPlayer(string audioUrl)
        {
            if (audioPlayer == null)
            {
                // initial video player
                audioPlayer                   = gameObject.AddComponent <VideoPlayer>();
                audioPlayer.renderMode        = VideoRenderMode.APIOnly;
                audioPlayer.source            = VideoSource.Url;
                audioPlayer.playOnAwake       = false;
                audioPlayer.waitForFirstFrame = true;
                audioPlayer.skipOnDrop        = false;
                audioPlayer.isLooping         = loop;

                // set audio output mode to AudioSource
                audioPlayer.audioOutputMode           = VideoAudioOutputMode.AudioSource;
                audioPlayer.controlledAudioTrackCount = 1;
                audioPlayer.EnableAudioTrack(0, true);
                audioPlayer.SetTargetAudioSource(0, audioSource);

                audioPlayer.prepareCompleted += OnAudioPrepareCompleted;
            }

            string validUrl = ValidParsedVideoUrl(mediaInfo, audioUrl);

            if (audioPlayer.url != validUrl)
            {
                audioPlayer.url = validUrl;
            }
        }
Ejemplo n.º 19
0
    private void Awake()
    {
        Application.runInBackground = true;
        Screen.sleepTimeout         = SleepTimeout.NeverSleep;

        Delay = 0f;

        VRSettings.enabled = false;

        Debug.Log("initialize server to listen on : " + port);
        server = new NetworkServerSimple();
        server.Listen(port);

        server.RegisterHandler(MsgType.Connect, OnServerConnect);
        server.RegisterHandler(MsgType.Disconnect, OnServerDisonnect);
        server.RegisterHandler(CustomMsgType.Pong, OnPongResponse);
        server.RegisterHandler(CustomMsgType.SyncVideoPlaybackTime, OnSyncVideoPlaybackTime);

                #if UNITY_IOS
        videoPlayer2.audioOutputMode = VideoAudioOutputMode.Direct;
                #else
        //Set Audio Output to AudioSource
        audioSource = gameObject.AddComponent <AudioSource>();
        videoPlayer2.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer2.SetTargetAudioSource(0, audioSource);
                #endif


        //Assign the Audio from Video to AudioSource to be played
        videoPlayer2.EnableAudioTrack(0, true);
        PlayLoopVideo2();
    }
Ejemplo n.º 20
0
        private void Awake()
        {
            // initial youtube-dl parser
            ytdlParser = GetComponent <YTDLParser>();

            // initial audio source
            audioSource             = gameObject.AddComponent <AudioSource>();
            audioSource.playOnAwake = false;

            // initial video player
            videoPlayer                   = gameObject.AddComponent <VideoPlayer>();
            videoPlayer.source            = VideoSource.Url;
            videoPlayer.playOnAwake       = false;
            videoPlayer.waitForFirstFrame = true;
            videoPlayer.skipOnDrop        = false;
            videoPlayer.isLooping         = loop;

            // set audio output mode to AudioSource
            videoPlayer.audioOutputMode           = VideoAudioOutputMode.AudioSource;
            videoPlayer.controlledAudioTrackCount = 1;
            videoPlayer.EnableAudioTrack(0, true);
            videoPlayer.SetTargetAudioSource(0, audioSource);

            // set video render type
            SwitchRenderType();
        }
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        videoPlayer = gameObject.AddComponent <VideoPlayer>();
        //Add AudioSource
        audioSource = gameObject.AddComponent <AudioSource>();
        //Disable Play on Awake for both Video and Audio
        videoPlayer.playOnAwake = false;
        audioSource.playOnAwake = false;
        audioSource.Pause();
        // Video clip from Url
        videoPlayer.source = VideoSource.Url;
        // videoPlayer.url = "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4";
        videoPlayer.url = "192.168.137.18:8080";

        //Set Audio Output to AudioSource
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        //Assign the Audio from Video to AudioSource to be played
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);
        //Set video To Play then prepare Audio to prevent Buffering
        videoPlayer.Prepare();

        //Play Video
        videoPlayer.Play();
        //Play Sound
        audioSource.Play();
    }
Ejemplo n.º 22
0
    private GameObject projector;                     //Objet dans le quel le lecteur audio et videos seront crées, permet de garder un hierarchie plus propre

    private void Awake()
    {
        playlist = new Dictionary <Sprite, VideoClip>();
        if (thumbnails.Count == videos.Count)            //Test pour s'assurer qu'on declare autant de video que de thumbnails
        {                                                //Si c'est le cas, on crée le lecteur video / son et on crée la liste des boutons a afficher
            for (int i = 0; i < thumbnails.Count; i++)   //Pour chaque element de la liste, on...
            {
                playlist.Add(thumbnails[i], videos[i]);  //...Attribue a playlist[i] la thumbnail et la video que l'on veux afficher, il y a autant de cases dans playlist que de boutons
            }
            Debug.Log("<b>Disctionnaire de vidéos crée : <color=magenta>" + thumbnails.Count + " éléments chargés</color></b>");

            //Code pour init le projo (ptdr aled)
            projector   = new GameObject("Projecteur Video 360");                     //Création de l'objet projector, comme expliqué plus haut, il permet de garder un hierarchie plus propre
            videoPlayer = projector.AddComponent <VideoPlayer>();                     //On ajoute le lecteur video a cet objet
            audioSource = projector.AddComponent <AudioSource>();                     //On ajoute le lecteur audio a cet objet


            videoPlayer.playOnAwake     = false; audioSource.playOnAwake = false;          //On empeche le lancement automatique des medias
            videoPlayer.source          = VideoSource.VideoClip;                           //On veux lire la video depuis un fichier et pas une url
            videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;                //On set la source audio en mode output
            videoPlayer.renderMode      = UnityEngine.Video.VideoRenderMode.RenderTexture; //On set le mode de rendu en mode rendu texture (Pour pouvoir streamer la video sur une texture)
            videoPlayer.EnableAudioTrack(0, true);                                         //On assigne le son de la video a notre source audio
            videoPlayer.SetTargetAudioSource(0, audioSource);

            Debug.Log("<b>Le player a été initialisé. (got : " + videoPlayer + ").</b>");
        }
        else
        {
            Debug.Log("<b><color=red>Erreur lors de la création du dictionnaire : le nombre de videos et de thumbnails ne correspondent pas</color></b>");
        }
    }
Ejemplo n.º 23
0
    void Start()
    {
        GameObject camera = GameObject.Find("HoloLensCamera");

        videoPlayer = camera.AddComponent <VideoPlayer>();
        audioSource = camera.AddComponent <AudioSource>();

        //Disable Play on Awake for both Video and Audio
        videoPlayer.playOnAwake = false;
        audioSource.playOnAwake = false;
        videoPlayer.clip        = videoClip;

        // Video settings
        videoPlayer.renderMode        = VideoRenderMode.CameraNearPlane;
        videoPlayer.aspectRatio       = VideoAspectRatio.FitVertically;
        videoPlayer.targetCameraAlpha = 1.0F;
        videoPlayer.isLooping         = false;

        // Audio settings
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);

        videoPlayer.loopPointReached += EndReached;

        audioSource.Play();
        videoPlayer.Play();
    }
Ejemplo n.º 24
0
    void Awake()
    {
        videoPlayer = this.GetComponent <VideoPlayer>();
        audioSource = videoPlayer.GetComponentInChildren <AudioSource>();
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);
        videoPlayer.controlledAudioTrackCount = 1;
        audioSource.volume            = 1.0f;
        videoPlayer.loopPointReached += ReloadVideoAndPlay;

        videoTexture = videoPlayer.targetTexture;

        material       = this.GetComponent <MeshRenderer>().material;
        material.color = Color.gray;

        transform.position = (transform.position - center).normalized * radius + center;
        transform.LookAt(center, Vector3.up);

        originalPosition           = transform.position;
        originalDistanceFromCamera = radius;
        originalRotationSpeed      = rotationSpeed;

        allInteractables = this.GetComponentsInParent <XRBaseInteractable>();
    }
Ejemplo n.º 25
0
    void InitializeVideo()
    {
        firstRun = false;
        //Add VideoPlayer to the GameObject
        videoPlayer = gameObject.AddComponent <VideoPlayer>();

        //Add AudioSource
        audioSource = gameObject.AddComponent <AudioSource>();

        //Disable Play on Awake for both Video and Audio
        videoPlayer.playOnAwake = false;
        audioSource.playOnAwake = false;
        audioSource.Pause();

        // Vide clip from Url
        videoPlayer.source    = VideoSource.Url;
        videoPlayer.url       = "https://s3.eu-central-1.amazonaws.com/admented/Alliance/2017-05/videos/agora.mp4";
        videoPlayer.isLooping = false;

        //Set Audio Output to AudioSource
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

        //Assign the Audio from Video to AudioSource to be played
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);

        // :: EVENT
        videoPlayer.prepareCompleted += Prepared;
        videoPlayer.loopPointReached += EndReached;
    }
Ejemplo n.º 26
0
        IEnumerator <float> Play()
        {
            PlayButton.SetActive(false);
            _firstRun = false;

            _videoPlayer = gameObject.AddComponent <VideoPlayer>();
            _audioSource = gameObject.AddComponent <AudioSource>();

            _videoPlayer.playOnAwake = false;
            _audioSource.playOnAwake = false;
            _audioSource.Pause();

            _videoPlayer.source          = VideoSource.VideoClip;
            _videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

            _videoPlayer.EnableAudioTrack(0, true);
            _videoPlayer.SetTargetAudioSource(0, _audioSource);

            _videoPlayer.clip = VideoClip;
            _videoPlayer.Prepare();

            while (!_videoPlayer.isPrepared)
            {
                yield return(Timing.WaitForOneFrame);
            }
            RawImage.texture = _videoPlayer.texture;

            _videoPlayer.Play();
            _audioSource.Play();

            while (_videoPlayer.isPlaying)
            {
                yield return(Timing.WaitForOneFrame);
            }
        }
        private void PlayVideo(string path)
        {
            if (isVideoPlaying || isVideoRecording || isFinishWriting || string.IsNullOrEmpty(path))
            {
                return;
            }

            Debug.Log("PlayVideo ()");

            isVideoPlaying = true;

            // Playback the video
            videoPlayer.renderMode  = VideoRenderMode.APIOnly;
            videoPlayer.playOnAwake = false;
            videoPlayer.isLooping   = false;

            // Unmute microphone
            microphoneSource.mute        = false;
            microphoneSource.playOnAwake = false;

            videoPlayer.source                    = VideoSource.Url;
            videoPlayer.url                       = path;
            videoPlayer.audioOutputMode           = VideoAudioOutputMode.AudioSource;
            videoPlayer.controlledAudioTrackCount = 1;
            videoPlayer.EnableAudioTrack(0, true);
            videoPlayer.SetTargetAudioSource(0, microphoneSource);

            videoPlayer.prepareCompleted += PrepareCompleted;
            videoPlayer.loopPointReached += EndReached;

            videoPlayer.Prepare();

            HideAllVideoUI();
        }
Ejemplo n.º 28
0
    public void Play(string clipName)
    {
        //string path = ContentController.ContentDirectory + "/" + clipName;
        videoClip = Resources.Load <VideoClip>(clipName);
        if (videoClip != null)
        {
            videoPlayer.clip = videoClip;
            videoPlayer.EnableAudioTrack(0, true);
            videoPlayer.SetTargetAudioSource(0, GetComponent <AudioSource>());
            videoPlayer.Play();
            videoPanel.alpha          = 1;
            videoPanel.interactable   = true;
            videoPanel.blocksRaycasts = true;

            videoControl.sprite = pause;

            videoTimeSlider.maxValue = (float)videoClip.length;



            ShowPage(Page.Video);

            FadeIn();

            Screen.orientation = ScreenOrientation.AutoRotation;
            Screen.autorotateToLandscapeLeft      = true;
            Screen.autorotateToLandscapeRight     = true;
            Screen.autorotateToPortrait           = true;
            Screen.autorotateToPortraitUpsideDown = true;

            navbarPanel.alpha          = 0;
            navbarPanel.interactable   = false;
            navbarPanel.blocksRaycasts = false;
        }
    }
 void InitVideoEngine()
 {
     videoPlayerList = new List <VideoPlayer>();
     for (int i = 0; i < CutsceneVideoLines.Length; i++)
     {
         GameObject camera = GameObject.Find("Main Camera");
         //Add VideoPlayer to the GameObject
         VideoPlayer videoPlayer = camera.AddComponent <VideoPlayer>();
         videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraFarPlane;
         videoPlayerList.Add(videoPlayer);
         videoPlayer.waitForFirstFrame = false;
         //Add AudioSource to the camera
         AudioSource audioSource = camera.AddComponent <AudioSource>();
         //Disable Play on Awake for both Video and Audio
         videoPlayer.playOnAwake = false;
         audioSource.playOnAwake = false;
         //We want to play from video clip not from url
         videoPlayer.source = VideoSource.VideoClip;
         //Set Audio Output to AudioSource
         videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
         //Assign the Audio from Video to AudioSource to be played
         videoPlayer.EnableAudioTrack(0, true);
         videoPlayer.SetTargetAudioSource(0, audioSource);
     }
 }
Ejemplo n.º 30
0
    IEnumerator playVideo()
    {
        videoPlayer = gameObject.AddComponent <VideoPlayer>();

        videoPlayer.playOnAwake = false;

        videoPlayer.source          = VideoSource.VideoClip;
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
        videoPlayer.EnableAudioTrack(0, true);

        videoPlayer.clip = videoToPlay;
        videoPlayer.Prepare();

        while (!videoPlayer.isPrepared)
        {
            yield return(null);
        }

        image.texture = videoPlayer.texture;
        videoPlayer.Play();

        while (videoPlayer.isPlaying)
        {
            yield return(null);
        }

        SceneManager.LoadScene(2);
    }