Exemple #1
0
        private IEnumerator initDecoderAsync(string path)
        {
            print(LOG_TAG + " init Decoder.");
            decoderState = DecoderNative.DecoderState.INITIALIZING;
            mediaPath    = path;
            decoderID    = -1;
            DecoderNative.nativeCreateDecoderAsync(mediaPath, ref decoderID);
            var result = 0;

            do
            {
                yield return(null);

                result = DecoderNative.nativeGetDecoderState(decoderID);
            } while (!(result == 1 || result == -1));

            //  Init success.
            if (result == 1)
            {
                print(LOG_TAG + " Init success.");
                isVideoEnabled = DecoderNative.nativeIsVideoEnabled(decoderID);
                //if (isVideoEnabled)
                //{
                //	var duration = 0.0f;
                //	DecoderNative.nativeGetVideoFormat(decoderID, ref videoWidth, ref videoHeight, ref duration);
                //	videoTotalTime = duration > 0 ? duration : -1.0f;
                //	print(LOG_TAG + " Video format: (" + videoWidth + ", " + videoHeight + ")");
                //	if (videoTotalTime > 0)
                //		print(LOG_TAG + " Total time: " + videoTotalTime);
                //	setTextures(null, null, null);
                //	useDefault = true;
                //}

                ////	Initialize audio.
                isAudioEnabled = DecoderNative.nativeIsAudioEnabled(decoderID);
                //print(LOG_TAG + " isAudioEnabled = " + isAudioEnabled);
                //if (isAudioEnabled)
                //{
                //	if (isAllAudioChEnabled)
                //	{
                //		DecoderNative.nativeSetAudioAllChDataEnable(decoderID, isAllAudioChEnabled);
                //		getAudioFormat();
                //	}
                //	else
                //	{
                //		getAudioFormat();
                //		initAudioSource();
                //	}
                //}
                decoderState = DecoderNative.DecoderState.INITIALIZED;
                if (onInitComplete != null)
                {
                    onInitComplete.Invoke();
                }
            }
            else
            {
                print(LOG_TAG + " Init fail.");
                decoderState = DecoderNative.DecoderState.INIT_FAIL;
            }
        }