Java Code Examples for com.google.android.exoplayer2.mediacodec.MediaCodecRenderer#DecoderInitializationException

The following examples show how to use com.google.android.exoplayer2.mediacodec.MediaCodecRenderer#DecoderInitializationException . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactExoplayerView.java    From react-native-video with MIT License 6 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = "ExoPlaybackException type : " + e.type;
    Exception ex = e;
    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
            // Special case for decoder initialization failures.
            MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                    (MediaCodecRenderer.DecoderInitializationException) cause;
            if (decoderInitializationException.codecInfo.name == null) {
                if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                    errorString = getResources().getString(R.string.error_querying_decoders);
                } else if (decoderInitializationException.secureDecoderRequired) {
                    errorString = getResources().getString(R.string.error_no_secure_decoder,
                            decoderInitializationException.mimeType);
                } else {
                    errorString = getResources().getString(R.string.error_no_decoder,
                            decoderInitializationException.mimeType);
                }
            } else {
                errorString = getResources().getString(R.string.error_instantiating_decoder,
                        decoderInitializationException.codecInfo.name);
            }
        }
    }
    else if (e.type == ExoPlaybackException.TYPE_SOURCE) {
        errorString = getResources().getString(R.string.unrecognized_media_format);
    }
    eventEmitter.error(errorString, ex);
    playerNeedsSource = true;
    if (isBehindLiveWindow(e)) {
        clearResumePosition();
        initializePlayer();
    } else {
        updateResumePosition();
    }
}
 
Example 2
Source File: VideoPlayerComponent.java    From android-arch-components-lifecycle with Apache License 2.0 5 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = null;
    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
            // Special case for decoder initialization failures.
            MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                    (MediaCodecRenderer.DecoderInitializationException) cause;
            if (decoderInitializationException.decoderName == null) {
                if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                    errorString = context.getString(R.string.error_querying_decoders);
                } else if (decoderInitializationException.secureDecoderRequired) {
                    errorString = context.getString(R.string.error_no_secure_decoder,
                            decoderInitializationException.mimeType);
                } else {
                    errorString = context.getString(R.string.error_no_decoder,
                            decoderInitializationException.mimeType);
                }
            } else {
                errorString = context.getString(R.string.error_instantiating_decoder,
                        decoderInitializationException.decoderName);
            }
        }
    }
    if (errorString != null) {
        showToast(errorString);
    }
    if (isBehindLiveWindow(e)) {
        clearResumePosition();
        initializePlayer();
    } else {
        updateResumePosition();

    }
}
 
Example 3
Source File: RendererErrorMapper.java    From no-player with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"PMD.StdCyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.ModifiedCyclomaticComplexity", "PMD.NPathComplexity"})
static NoPlayer.PlayerError map(Exception rendererException, String message) {
    if (rendererException instanceof AudioSink.ConfigurationException) {
        return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_CONFIGURATION_ERROR, message);
    }

    if (rendererException instanceof AudioSink.InitializationException) {
        return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_INITIALISATION_ERROR, message);
    }

    if (rendererException instanceof AudioSink.WriteException) {
        return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_WRITE_ERROR, message);
    }

    if (rendererException instanceof AudioProcessor.UnhandledFormatException) {
        return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_UNHANDLED_FORMAT_ERROR, message);
    }

    if (rendererException instanceof AudioDecoderException) {
        return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_DECODER_ERROR, message);
    }

    if (rendererException instanceof MediaCodecRenderer.DecoderInitializationException) {
        MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                (MediaCodecRenderer.DecoderInitializationException) rendererException;
        String fullMessage = "decoder-name:" + decoderInitializationException.decoderName + ", "
                + "mimetype:" + decoderInitializationException.mimeType + ", "
                + "secureCodeRequired:" + decoderInitializationException.secureDecoderRequired + ", "
                + "diagnosticInfo:" + decoderInitializationException.diagnosticInfo + ", "
                + "exceptionMessage:" + message;
        return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.INITIALISATION_ERROR, fullMessage);
    }

    if (rendererException instanceof MediaCodecUtil.DecoderQueryException) {
        return new NoPlayerError(PlayerErrorType.DEVICE_MEDIA_CAPABILITIES, DetailErrorType.UNKNOWN, message);
    }

    if (rendererException instanceof SubtitleDecoderException) {
        return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.DECODING_SUBTITLE_ERROR, message);
    }

    if (rendererException instanceof UnsupportedDrmException) {
        return mapUnsupportedDrmException((UnsupportedDrmException) rendererException, message);
    }

    if (rendererException instanceof DefaultDrmSessionManager.MissingSchemeDataException) {
        return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.CANNOT_ACQUIRE_DRM_SESSION_MISSING_SCHEME_FOR_REQUIRED_UUID_ERROR, message);
    }

    if (rendererException instanceof DrmSession.DrmSessionException) {
        return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.DRM_SESSION_ERROR, message);
    }

    if (rendererException instanceof KeysExpiredException) {
        return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.DRM_KEYS_EXPIRED_ERROR, message);
    }

    if (rendererException instanceof DecryptionException) {
        return new NoPlayerError(PlayerErrorType.CONTENT_DECRYPTION, DetailErrorType.FAIL_DECRYPT_DATA_DUE_NON_PLATFORM_COMPONENT_ERROR, message);
    }

    if (rendererException instanceof MediaCodec.CryptoException) {
        return mapCryptoException((MediaCodec.CryptoException) rendererException, message);
    }

    if (rendererException instanceof IllegalStateException) {
        return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.MEDIA_REQUIRES_DRM_SESSION_MANAGER_ERROR, message);
    }

    return new NoPlayerError(PlayerErrorType.UNKNOWN, DetailErrorType.UNKNOWN, message);
}
 
Example 4
Source File: ExoPlayerHelper.java    From ExoPlayer-Wrapper with Apache License 2.0 4 votes vote down vote up
@Override
public void onPlayerError(ExoPlaybackException e) {
    String errorString = null;

    switch (e.type) {
        case ExoPlaybackException.TYPE_SOURCE:
            //https://github.com/google/ExoPlayer/issues/2702
            IOException ex = e.getSourceException();
            String msg = ex.getMessage();
            if (msg != null) {
                Log.e("ExoPlayerHelper", msg);
                errorString = msg;
            }
            break;
        case ExoPlaybackException.TYPE_RENDERER:
            Exception exception = e.getRendererException();
            if (exception.getMessage() != null) {
                Log.e("ExoPlayerHelper", exception.getMessage());
            }
            break;
        case ExoPlaybackException.TYPE_UNEXPECTED:
            RuntimeException runtimeException = e.getUnexpectedException();
            Log.e("ExoPlayerHelper", runtimeException.getMessage() == null ? "Message is null" : runtimeException.getMessage());
            if (runtimeException.getMessage() == null) {
                runtimeException.printStackTrace();
            }
            errorString = runtimeException.getMessage();
            break;
        case ExoPlaybackException.TYPE_OUT_OF_MEMORY:
            break;
        case ExoPlaybackException.TYPE_REMOTE:
            break;
    }


    if (e.type == ExoPlaybackException.TYPE_RENDERER) {
        Exception cause = e.getRendererException();
        if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
            // Special case for decoder initialization failures.
            MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                    (MediaCodecRenderer.DecoderInitializationException) cause;
            if (decoderInitializationException.decoderName == null) {
                if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                    errorString = mContext.getString(R.string.error_querying_decoders);
                } else if (decoderInitializationException.secureDecoderRequired) {
                    errorString = mContext.getString(R.string.error_no_secure_decoder,
                            decoderInitializationException.mimeType);
                } else {
                    errorString = mContext.getString(R.string.error_no_decoder,
                            decoderInitializationException.mimeType);
                }
            } else {
                errorString = mContext.getString(R.string.error_instantiating_decoder,
                        decoderInitializationException.decoderName);
            }
        }
    }
    if (errorString != null) {
        Log.e("ExoPlayerHelper", "errorString: " + errorString);
    }

    if (isBehindLiveWindow(e)) {
        createPlayer(true);
        Log.e("ExoPlayerHelper", "isBehindLiveWindow is true");
    }


    if (mExoPlayerListener != null) {
        mExoPlayerListener.onPlayerError(errorString);
    }
}
 
Example 5
Source File: VideoActivity.java    From evercam-android with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
    public void onPlayerError(ExoPlaybackException error) {
        String errorString = null;
        if (error.type == ExoPlaybackException.TYPE_RENDERER) {
            Exception cause = error.getRendererException();
            if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
                // Special case for decoder initialization failures.
                MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
                        (MediaCodecRenderer.DecoderInitializationException) cause;
                if (decoderInitializationException.decoderName == null) {
                    if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
                        errorString = getString(R.string.error_querying_decoders);
                    } else if (decoderInitializationException.secureDecoderRequired) {
                        errorString = getString(R.string.error_no_secure_decoder,
                                decoderInitializationException.mimeType);
                    } else {
                        errorString = getString(R.string.error_no_decoder,
                                decoderInitializationException.mimeType);
                    }
                } else {
                    errorString = getString(R.string.error_instantiating_decoder,
                            decoderInitializationException.decoderName);
                }
            }
        }
        if (errorString != null) {
            Log.e(TAG, errorString);
        }

        if (isBehindLiveWindow(error)) {
            clearResumePosition();
            preparePlayer();
        } else {
            Log.e("VIDEO FAILED","VIDEO FAILED LOADING NEW ONE.");
            updateResumePosition();
            onVideoLoadFailed();
        }



/*        Log.e(TAG, "onError");
        onVideoLoadFailed();
        playerNeedsPrepare = true;*/

    }