@Override public void onAudioDisabled(DecoderCounters counters) { if (audioDebugListener != null) { audioDebugListener.onAudioDisabled(counters); } audioFormat = null; audioDecoderCounters = null; audioSessionId = AudioTrack.SESSION_ID_NOT_SET; }
SimpleExoPlayer(Context context, TrackSelector<?> trackSelector, LoadControl loadControl, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, boolean preferExtensionDecoders, long allowedVideoJoiningTimeMs) { mainHandler = new Handler(); componentListener = new ComponentListener(); trackSelector.addListener(componentListener); // Build the renderers. ArrayList<Renderer> renderersList = new ArrayList<>(); if (preferExtensionDecoders) { buildExtensionRenderers(renderersList, allowedVideoJoiningTimeMs); buildRenderers(context, drmSessionManager, renderersList, allowedVideoJoiningTimeMs); } else { buildRenderers(context, drmSessionManager, renderersList, allowedVideoJoiningTimeMs); buildExtensionRenderers(renderersList, allowedVideoJoiningTimeMs); } renderers = renderersList.toArray(new Renderer[renderersList.size()]); // Obtain counts of video and audio renderers. int videoRendererCount = 0; int audioRendererCount = 0; for (Renderer renderer : renderers) { switch (renderer.getTrackType()) { case C.TRACK_TYPE_VIDEO: videoRendererCount++; break; case C.TRACK_TYPE_AUDIO: audioRendererCount++; break; } } this.videoRendererCount = videoRendererCount; this.audioRendererCount = audioRendererCount; // Set initial values. audioSessionId = AudioTrack.SESSION_ID_NOT_SET; volume = 1; // Build the player and associated objects. player = new ExoPlayerImpl(renderers, trackSelector, loadControl); }
private void initAudioTrack() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { AudioTrack.enablePreV21AudioSessionWorkaround = true; } }