コード例 #1
0
        //  Video progress is triggered using Update. Progress time would be set by nativeSetVideoTime.
        private void Update()
        {
            switch (decoderState)
            {
            case DecoderNative.DecoderState.START:
                if (isVideoEnabled)
                {
                    //  Prevent empty texture generate green screen.(default 0,0,0 in YUV which is green in RGB)
                    if (useDefault && DecoderNative.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 && DecoderNative.nativeIsContentReady(decoderID))
                        {
                            setPause();
                            seekPreview = false;
                            unmute();
                        }
                        else
                        {
                            DecoderNative.nativeSetVideoTime(decoderID, (float)setTime);
                            GL.IssuePluginEvent(DecoderNative.GetRenderEventFunc(), decoderID);
                        }
                    }
                    else
                    {
                        isVideoReadyToReplay = true;
                    }
                }
                if (DecoderNative.nativeIsVideoBufferEmpty(decoderID) && !DecoderNative.nativeIsEOF(decoderID))
                {
                    decoderState = DecoderNative.DecoderState.BUFFERING;
                    hangTime     = curRealTime - globalStartTime;
                }
                break;

            case DecoderNative.DecoderState.SEEK_FRAME:
                if (DecoderNative.nativeIsSeekOver(decoderID))
                {
                    globalStartTime = curRealTime - hangTime;
                    decoderState    = DecoderNative.DecoderState.START;
                    if (lastState == DecoderNative.DecoderState.PAUSE)
                    {
                        seekPreview = true;
                        mute();
                    }
                }
                break;

            case DecoderNative.DecoderState.BUFFERING:
                if (!DecoderNative.nativeIsVideoBufferEmpty(decoderID) || DecoderNative.nativeIsEOF(decoderID))
                {
                    decoderState    = DecoderNative.DecoderState.START;
                    globalStartTime = curRealTime - hangTime;
                }
                break;

            case DecoderNative.DecoderState.PAUSE:
            case DecoderNative.DecoderState.EOF:
            default:
                break;
            }
            if (isVideoEnabled || isAudioEnabled)
            {
                if ((!isVideoEnabled || isVideoReadyToReplay) && (!isAudioEnabled || isAudioReadyToReplay))
                {
                    decoderState         = DecoderNative.DecoderState.EOF;
                    isVideoReadyToReplay = isAudioReadyToReplay = false;
                    if (onVideoEnd != null)
                    {
                        onVideoEnd.Invoke();
                    }
                }
            }
        }
コード例 #2
0
 public bool isSeeking()
 {
     return(decoderState >= DecoderNative.DecoderState.INITIALIZED && (decoderState == DecoderNative.DecoderState.SEEK_FRAME || !DecoderNative.nativeIsContentReady(decoderID)));
 }