// Update is called once per frame void Update() { if (this.tcpServer.IsDataAvailable()) { ixVideo = this.tcpServer.ReadCommand(); Debug.Log("Datum received: " + ixVideo.ToString()); // Quit was requested if (ixVideo == 66) { Application.Quit(); } // Video was requested else { // Load video in Player videoPlayer.source = UnityEngine.Video.VideoSource.VideoClip; videoPlayer.clip = Resources.Load("video_" + ixVideo.ToString("D2")) as UnityEngine.Video.VideoClip; // Set AudioSource videoPlayer.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource; videoPlayer.SetTargetAudioSource(0, screen.GetComponent <UnityEngine.AudioSource>()); prepareVideo = true; } } // Video needs to be prepared if (prepareVideo) { videoPlayer.Prepare(); prepareVideo = false; } // Play the video if it's prepared if (videoPlayer.isPrepared & !videoRemotePlay) { // Play Video videoPlayer.Play(); // String ix_video Debug.Log("Playing video: " + ixVideo.ToString("D2")); // Set flag of remote play videoRemotePlay = true; } // Check that Video was remotely started and is over if (videoRemotePlay & !videoPlayer.isPlaying) { videoRemotePlay = false; tcpServer.WriteInt32(ixVideo); Debug.Log("End of video: " + ixVideo.ToString("D2")); videoPlayer.Stop(); } }
// Update is called once per frame void Update() { if (this.tcp_server.IsDataAvailable()) { int command = this.tcp_server.ReadCommand(); Debug.Log("Command: " + command.ToString()); switch (command) { case 1: print("Play Video1"); video1Player.Play(); video1_remoteplay = true; break; case 2: print("Play Video2"); video2Player.Play(); video2_remoteplay = true; break; case 3: print("Play Video3"); video3Player.Play(); video3_remoteplay = true; break; case 4: print("Play Video4"); video4Player.Play(); video4_remoteplay = true; break; case 5: print("Play Video5"); video5Player.Play(); video5_remoteplay = true; break; case 6: print("Play Video6"); video6Player.Play(); video6_remoteplay = true; break; case 66: Application.Quit(); break; } } if (video1_remoteplay & !video1Player.isPlaying) { video1_remoteplay = false; tcp_server.WriteInt32(11); print("Trigger for Video 1 end"); video1Player.Stop(); } if (video2_remoteplay & !video2Player.isPlaying) { video2_remoteplay = false; tcp_server.WriteInt32(12); print("Trigger for Video 2 end"); video2Player.Stop(); } if (video3_remoteplay & !video3Player.isPlaying) { video3_remoteplay = false; tcp_server.WriteInt32(13); print("Trigger for Video 3 end"); video3Player.Stop(); } if (video4_remoteplay & !video4Player.isPlaying) { video4_remoteplay = false; tcp_server.WriteInt32(14); print("Trigger for Video 4 end"); video4Player.Stop(); } if (video5_remoteplay & !video5Player.isPlaying) { video5_remoteplay = false; tcp_server.WriteInt32(15); print("Trigger for Video 5 end"); video5Player.Stop(); } if (video6_remoteplay & !video6Player.isPlaying) { video6_remoteplay = false; tcp_server.WriteInt32(16); print("Trigger for Video 6 end"); video6Player.Stop(); } }