// Use this for initialization void Start() { //Debug.Log("Initializing playable clip!" + this.ToString()); _headTrack = GetComponent <HeadTrack>(); _mesh = this.GetComponent <MeshRenderer>(); _mesh.material.shader = Shader.Find("Inside Sphere Blend"); }
public int MinLoopLengthFrames() { HeadTrack headtrack = _Sphere.GetComponent <HeadTrack>(); int frames = (int)Math.Round(minLoopLengthSec * headtrack.GetVideoFps()); return(frames); }
public void MarkStoryPoint(GameObject sphere) { Debug.Log("Mark story point " + Gated + " to " + !Gated); RemoveCurrentComponent(sphere); Gated = !Gated; GenerateAndUpdateComponents(sphere); HeadTrack headtrack = sphere.GetComponent <HeadTrack>(); headtrack.RefreshTimeline(); }
public virtual bool checkSalient(float currentTime, MultiplePlayerControl multiMedia, HeadTrack _headtrack) { if (_headTrack == null) { _headTrack = GetComponent <HeadTrack>(); } MediaPlayer player = multiMedia.Player; float threshold = 1.0f / _headtrack.GetVideoFps(); if (Math.Abs(currentTime - endTime) < threshold) { return(true); // Saliency means we passed this clip. Can move pointer to next clip. } return(false); }
public override bool checkSalient(float currentTime, MultiplePlayerControl multiMedia, HeadTrack _headtrack) { float relativeTime = currentTime - this.startTime; int currentFrame = (int)(relativeTime * multiMedia.Player.Info.GetVideoFrameRate()); int gateFrame = (int)(this.gateTime * multiMedia.Player.Info.GetVideoFrameRate()); int curView = _headTrack.GetVisibleView(); if (_currentView != curView) { if (multiMedia.isTransitioning && multiMedia.currentLoopArc.toTime > multiMedia.currentLoopArc.fromTime) { Debug.Log("VIEW CHANGED IN MIDDLE OF TRANSITION. Was " + _currentView + ". Now: " + curView + ". Calling FinishTransition."); multiMedia.FinishTransition(); } if (multiMedia.IsPaused()) { if (GetComponent <PreviewMode>().requestedPlayMode) { Debug.Log("CURVIEW WAS IN PAUSED STATE. Now: " + curView + ". Playing again."); _headtrack.playMode = true; } } _currentView = curView; } if (!_ROIWithinView) { if (isTargetView(curView)) { _ROIWithinView = true; if (multiMedia.isTransitioning) { Debug.Log("TARGET CAME INTO VIEW AGAIN. Calling FinishTransition"); multiMedia.FinishTransition(); } if (multiMedia.IsPaused()) { _headtrack.playMode = true; multiMedia.Play(); } } } if (multiMedia.isTransitioning && (!isTargetView(curView) && sp.IsCutFrame(curView, currentFrame))) { Debug.Log("Current frame: " + currentFrame + ". Entered another valid frame when transitioning.... Exiting transition"); multiMedia.FinishTransition(); Debug.Log("Exited? " + !multiMedia.isTransitioning); } if (multiMedia.isTransitioning) { Debug.Log("Current loop is " + multiMedia.currentLoopArc); multiMedia.UnidirectionalTransition(); multiMedia.expectedCurrentFrame = currentFrame; multiMedia.expectedNextFrame = currentFrame + 1; } else { Transition(currentFrame, _currentView, multiMedia, _headtrack); } return(currentTime > this.endTime); // Return true if Headtrack can move onto the next clip. Else false. }
public void Transition(int currentFrame, int curView, MultiplePlayerControl multiMedia, HeadTrack _headtrack) { int gateFrame = (int)(this.gateTime * multiMedia.Player.Info.GetVideoFrameRate()); if (!isTargetView(curView) && (multiMedia.expectedCurrentFrame == gateFrame || multiMedia.expectedNextFrame == gateFrame) && currentFrame != multiMedia.expectedCurrentFrame && currentFrame != multiMedia.expectedNextFrame) { Debug.LogError("SKIPPED GATE FRAME!"); } else if (currentFrame > gateFrame || isTargetView(curView)) { multiMedia.expectedCurrentFrame = currentFrame; multiMedia.expectedNextFrame = currentFrame + 1; if (sp.jumpImmediately && currentFrame < gateFrame - HeadTrack._LOOP_TRANS_DURATION && isTargetView(curView)) { int jumpToFrame = gateFrame - (int)(HeadTrack._LOOP_TRANS_DURATION * multiMedia.Player.Info.GetVideoFrameRate()); if (sp.views[curView].CanJumpTo(currentFrame, jumpToFrame, sp.jumpThreshold)) { float jumpToTime = this.gateTime - HeadTrack._LOOP_TRANS_DURATION; Debug.Log("Frame rate: " + multiMedia.Player.Info.GetVideoFrameRate()); Debug.Log("Sp start time: " + sp.startTime + " Jump to time: " + jumpToTime); Debug.Log("GOING to jump from " + (sp.startTime + 1f * currentFrame / multiMedia.Player.Info.GetVideoFrameRate()) + " to time " + (sp.startTime + jumpToTime)); this.sp.views[curView].AddLoopArc(sp.startTime + 1f * currentFrame / multiMedia.Player.Info.GetVideoFrameRate(), sp.startTime + jumpToTime, sp.startTime, sp.endTime); Debug.Log("Sp now has " + this.sp.views[curView].GetLoopArcs().Count() + " looparcs"); LoopArc currentLoop = this.sp.views[curView].GetCurrentLoop(); multiMedia.currentLoopArc = currentLoop; multiMedia._mediaOffset = currentLoop.fromTime - currentLoop.toTime; Debug.Log("Media current loop arc is " + multiMedia.currentLoopArc + ". Set media offset to " + multiMedia._mediaOffset); // Seek to apply media offset. multiMedia.isTransitioning = true; multiMedia.SyncMediaPlayers(); multiMedia.expectedCurrentFrame = jumpToFrame; multiMedia.expectedNextFrame = jumpToFrame + 1; } } return; // Don't transition if current frame is past gate frame. } int jumpTo; int fromFrame = currentFrame; if (sp.ReachedCutFrame(curView, currentFrame)) { jumpTo = sp.FindJumpToFrame(curView, currentFrame); Debug.Log("Reached cut frame. Jumping to: " + jumpTo); } else if (sp.PastLastCutFrame(curView, currentFrame)) // May happen if computer suddenly lagged and missed a frame update. { Debug.LogWarning("ERROR! REACHED DANGER ZONE " + curView + ", " + currentFrame); int lastCutFrame = sp.FindLastCutFrame(curView); jumpTo = sp.FindJumpToFrame(curView, lastCutFrame); fromFrame = lastCutFrame; } else { jumpTo = currentFrame + 1; } multiMedia.expectedCurrentFrame = currentFrame; multiMedia.expectedNextFrame = jumpTo; if (jumpTo == currentFrame) { Debug.Log("Paused media player because jumpto " + jumpTo + " is same as current frame: " + currentFrame); _headtrack.playMode = false; multiMedia.Pause(); } else if (jumpTo != currentFrame + 1) // if jumping to a frame that's not the next frame, then perform a seek. Otherwise just keep playing. { float jumpToTime = 1f * jumpTo / multiMedia.Player.Info.GetVideoFrameRate(); Debug.Log("Frame rate: " + multiMedia.Player.Info.GetVideoFrameRate()); Debug.Log("Sp start tiem: " + sp.startTime + " Jump to time: " + jumpToTime); Debug.Log("GOING to jump from " + (sp.startTime + 1f * currentFrame / multiMedia.Player.Info.GetVideoFrameRate()) + " to time " + (sp.startTime + jumpToTime)); this.sp.views[curView].AddLoopArc(sp.startTime + currentFrame / multiMedia.Player.Info.GetVideoFrameRate(), sp.startTime + jumpToTime, sp.startTime, sp.endTime); Debug.Log("Sp now has " + this.sp.views[curView].GetLoopArcs().Count() + " looparcs"); // Set media offset. LoopArc currentLoop = this.sp.views[curView].GetCurrentLoop(); multiMedia.currentLoopArc = currentLoop; multiMedia._mediaOffset = currentLoop.fromTime - currentLoop.toTime; Debug.Log("Set media offset to " + multiMedia._mediaOffset); // Seek to apply media offset. multiMedia.isTransitioning = true; multiMedia.SyncMediaPlayers(); multiMedia.expectedCurrentFrame = jumpTo; multiMedia.expectedNextFrame = jumpTo + 1; } }