// Video progress is triggered using Update. Progress time would be set by nativeSetVideoTime. private void Update() { switch (decoderState) { case NativeClass.DecoderState.START: if (isVideoEnabled) { // Prevent empty texture generate green screen.(default 0,0,0 in YUV which is green in RGB) if (useDefault && NativeClass.nativeIsContentReady(decoderID)) { getTextureFromNative(); setTextures(videoTexYch, videoTexUch, videoTexVch); useDefault = false; } // Update video frame by dspTime. var setTime = curRealTime - globalStartTime; // Normal update frame. if (setTime < videoTotalTime || videoTotalTime <= 0) { if (seekPreview && NativeClass.nativeIsContentReady(decoderID)) { setPause(); seekPreview = false; unmute(); } else { NativeClass.nativeSetVideoTime(decoderID, (float)setTime); GL.IssuePluginEvent(NativeClass.GetRenderEventFunc(), decoderID); } } else { isVideoReadyToReplay = true; } } if (NativeClass.nativeIsVideoBufferEmpty(decoderID) && !NativeClass.nativeIsEOF(decoderID)) { decoderState = NativeClass.DecoderState.BUFFERING; hangTime = curRealTime - globalStartTime; } break; case NativeClass.DecoderState.SEEK_FRAME: if (NativeClass.nativeIsSeekOver(decoderID)) { globalStartTime = curRealTime - hangTime; decoderState = NativeClass.DecoderState.START; if (lastState == NativeClass.DecoderState.PAUSE) { seekPreview = true; mute(); } } break; case NativeClass.DecoderState.BUFFERING: if (!NativeClass.nativeIsVideoBufferEmpty(decoderID) || NativeClass.nativeIsEOF(decoderID)) { decoderState = NativeClass.DecoderState.START; globalStartTime = curRealTime - hangTime; } break; case NativeClass.DecoderState.PAUSE: case NativeClass.DecoderState.EOF: default: break; } if (isVideoEnabled || isAudioEnabled) { if ((!isVideoEnabled || isVideoReadyToReplay) && (!isAudioEnabled || isAudioReadyToReplay)) { decoderState = NativeClass.DecoderState.EOF; isVideoReadyToReplay = isAudioReadyToReplay = false; if (onVideoEnd != null) { onVideoEnd.Invoke(); } } } }