public void PauseVideo() { if (_multipleMedia != null) { _multipleMedia.Pause(); } else { Debug.Log("Player not initialized."); } }
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; } }