Audio files not played completely by ExoPlayer on Android 5.0 device, ok on Android 9

0

I'm using Exoplayer to play short mp3 (voice) files, and my code works fine on the Moto G6 running Android 9 which I've been using to develop the app. But running it on a Samsung S4 on Android 5.0, about half a second is not played at the end of each clip.

I'm using Exoplayer as the user often has option to play clips at slow speed, and I understand MediaPlayer won't do this for <6.0 while SoundPool's rate adjustment lowers the pitch too, which I don't want. When playing clips slowly, the same duration seems to be missing from the end, rather than the same proportion, so more of each is heard but they still get cut off. The files are played from a local folder where they are downloaded to the first time an activity is opened. I have some other audio clips in a raw folder that play through MediaPlayer and these do not get cut off on either device.

I'm posting my Exoplayer method and the stack traces from each device after it's called - I added an event logger. I've no idea why the 5.0 device stack trace has lines referring to video while the other doesn't, but I suspect the line '10-04 15:20:25.420 8358-8625/com.englishdreaming.appily E/AudioTrack: AudioTrack::set : Exit' may be helpful to someone who can read stack traces better than me - it's coloured the way fatal exceptions are, and only occurs in the 5.0 stack trace.

At an earlier point in the development I remember having a similar issue with the end of audio files being cut off, and that was on the Android 9 device, but I can't remember how I resolved that, or if it resolved itself - but now it works fine on 9 but not on 5.0. Thanks very much for any ideas on how I can fix it now.

    public void initExoplayer(int position) {
        Log.d(TAG, "initExoplayer:    CALLED");
        System.out.println("   mUris.SIZE is..  " + mUris.size() + "   and POSITION is...   " + position);

        mpFinished = false;
        
        TrackSelector trackSelector = new DefaultTrackSelector();
        player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
                Util.getUserAgent(getApplicationContext(), "appily"));
        Uri clickedUri = mUris.get(position);
        MediaSource audioSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(clickedUri);
        player.prepare(audioSource);

        player.addAnalyticsListener(new EventLogger(null));
        player.addListener(new Player.EventListener() {
            @Override
            public void onTimelineChanged(Timeline timeline, @Nullable Object manifest, int reason) {

            }

            @Override
            public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {

            }

            @Override
            public void onLoadingChanged(boolean isLoading) {

            }

            @Override
            public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {

                switch (playbackState) {
                    case Player.STATE_BUFFERING:
                        break;
                    case Player.STATE_ENDED:

                        mpFinished = true;

                        if (player != null) {
                            player.release();
                            player = null;
                        }
                        break;
                    case Player.STATE_IDLE:
                        break;
                    case Player.STATE_READY:
                        break;
                    default:
                        break;
                }
            }

            @Override
            public void onRepeatModeChanged(int repeatMode) {

            }

            @Override
            public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {

            }

            @Override
            public void onPlayerError(ExoPlaybackException error) {

            }

            @Override
            public void onPositionDiscontinuity(int reason) {

            }

            @Override
            public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {

            }

            @Override
            public void onSeekProcessed() {

            }
        });

        if (isSlow) {
            PlaybackParameters param = new PlaybackParameters(0.6f);
            player.setPlaybackParameters(param);
        }

        player.setPlayWhenReady(true);
    }

Stack trace from Moto g6 running Android 9:

2020-10-04 15:12:30.821 11918-11918/com.englishdreaming.appily D/SpellingActivity: initExoplayer:    CALLED
2020-10-04 15:12:30.821 11918-11918/com.englishdreaming.appily I/System.out:    mUris.SIZE is..  10   and POSITION is...   0
2020-10-04 15:12:30.824 11918-11918/com.englishdreaming.appily I/ExoPlayerImpl: Init 1bfc9f [ExoPlayerLib/2.8.4] [evert_n, moto g(6) plus, motorola, 28]
2020-10-04 15:12:30.835 11918-11918/com.englishdreaming.appily D/EventLogger: state [0.00, 0.00, window=0, true, BUFFERING]
2020-10-04 15:12:30.845 11918-11918/com.englishdreaming.appily D/Constraints: getView: CALLED
2020-10-04 15:12:30.857 11918-11918/com.englishdreaming.appily I/chatty: uid=10291(com.englishdreaming.appily) identical 1 line
2020-10-04 15:12:30.875 11918-11918/com.englishdreaming.appily D/Constraints: getView: CALLED
2020-10-04 15:12:30.884 11918-13009/com.englishdreaming.appily I/MediaCodec: (0x7308701a00) init name(OMX.google.mp3.decoder)
2020-10-04 15:12:30.887 11918-13011/com.englishdreaming.appily I/OMXClient: IOmx service obtained
2020-10-04 15:12:30.889 11918-11918/com.englishdreaming.appily D/Constraints: getView: CALLED
2020-10-04 15:12:30.889 11918-13011/com.englishdreaming.appily I/MediaCodec: (0x7308701a00) Component Allocated (OMX.google.mp3.decoder)
2020-10-04 15:12:30.890 11918-13009/com.englishdreaming.appily I/MediaCodec: (0x7308701a00) configure surface(0x0) crypto(0x0) flags(0)
2020-10-04 15:12:30.890 11918-13009/com.englishdreaming.appily D/MediaCodec: (0x7308701a00) configure format: AMessage(what = 0x00000000) = {
          int32_t sample-rate = 44100
          string mime = "audio/mpeg"
          int32_t channel-count = 2
          int32_t priority = 0
          int32_t max-input-size = 4096
        }
2020-10-04 15:12:30.891 11918-13011/com.englishdreaming.appily I/ACodec: codec does not support config priority (err -2147483648)
2020-10-04 15:12:30.892 11918-13009/com.englishdreaming.appily I/MediaCodec: (0x7308701a00) start
2020-10-04 15:12:30.899 11918-13011/com.englishdreaming.appily I/MediaCodec: (0x7308701a00) kWhatStartCompleted
2020-10-04 15:12:30.901 11918-11918/com.englishdreaming.appily D/Constraints: getView: CALLED
2020-10-04 15:12:30.915 11918-13011/com.englishdreaming.appily D/MediaCodec: (0x7308701a00) [OMX.google.mp3.decoder] output format changed to: AMessage(what = 0x00000000) = {
          string mime = "audio/raw"
          int32_t channel-count = 2
          int32_t sample-rate = 44100
          int32_t pcm-encoding = 2
        }
2020-10-04 15:12:30.924 11918-11918/com.englishdreaming.appily D/EventLogger: timelineChanged [0.10, 0.00, window=0, periodCount=1, windowCount=1, reason=PREPARED
2020-10-04 15:12:30.924 11918-11918/com.englishdreaming.appily D/EventLogger:   period [?]
2020-10-04 15:12:30.924 11918-11918/com.englishdreaming.appily D/EventLogger:   window [?, false, false]
2020-10-04 15:12:30.924 11918-11918/com.englishdreaming.appily D/EventLogger: ]
2020-10-04 15:12:30.925 11918-11918/com.englishdreaming.appily D/EventLogger: mediaPeriodCreated [0.10, 0.00, window=0, period=0]
2020-10-04 15:12:30.927 11918-11918/com.englishdreaming.appily D/EventLogger: loading [0.10, 0.00, window=0, period=0, true]
2020-10-04 15:12:30.932 11918-11918/com.englishdreaming.appily D/EventLogger: timelineChanged [0.10, 0.00, window=0, period=0, periodCount=1, windowCount=1, reason=DYNAMIC
2020-10-04 15:12:30.932 11918-11918/com.englishdreaming.appily D/EventLogger:   period [0.76]
2020-10-04 15:12:30.932 11918-11918/com.englishdreaming.appily D/EventLogger:   window [0.76, true, false]
2020-10-04 15:12:30.932 11918-11918/com.englishdreaming.appily D/EventLogger: ]
2020-10-04 15:12:30.933 11918-11918/com.englishdreaming.appily D/EventLogger: decoderEnabled [0.10, 0.00, window=0, period=0, audio]
2020-10-04 15:12:30.934 11918-11918/com.englishdreaming.appily D/EventLogger: tracksChanged [0.11, 0.00, window=0, period=0, []]
2020-10-04 15:12:30.935 11918-11918/com.englishdreaming.appily D/EventLogger: mediaPeriodReadingStarted [0.11, 0.00, window=0, period=0]
2020-10-04 15:12:30.936 11918-11918/com.englishdreaming.appily D/EventLogger: decoderInitialized [0.11, 0.00, window=0, period=0, audio, OMX.google.mp3.decoder]
2020-10-04 15:12:30.937 11918-11918/com.englishdreaming.appily D/EventLogger: decoderInputFormatChanged [0.11, 0.00, window=0, period=0, audio, id=null, mimeType=audio/mpeg, channels=2, sample_rate=44100]
2020-10-04 15:12:30.938 11918-11918/com.englishdreaming.appily D/EventLogger: loading [0.11, 0.00, window=0, period=0, false]
2020-10-04 15:12:30.939 11918-11918/com.englishdreaming.appily D/EventLogger: state [0.11, 0.00, window=0, period=0, true, READY]
2020-10-04 15:12:30.940 11918-11918/com.englishdreaming.appily D/EventLogger: downstreamFormatChanged [0.11, 0.00, window=0, period=0, id=null, mimeType=audio/mpeg, channels=2, sample_rate=44100]
2020-10-04 15:12:30.941 11918-11918/com.englishdreaming.appily D/EventLogger: audioSessionId [0.11, 0.00, window=0, period=0, 5489]
2020-10-04 15:12:31.493 11918-13009/com.englishdreaming.appily D/AudioTrack: stop() called with 32315 frames delivered
2020-10-04 15:12:31.882 11918-11918/com.englishdreaming.appily D/EventLogger: state [1.05, 0.76, window=0, period=0, true, ENDED]
2020-10-04 15:12:31.882 11918-11918/com.englishdreaming.appily I/ExoPlayerImpl: Release 1bfc9f [ExoPlayerLib/2.8.4] [evert_n, moto g(6) plus, motorola, 28] [goog.exo.core]
2020-10-04 15:12:31.884 11918-13009/com.englishdreaming.appily I/MediaCodec: (0x7308701a00) stop
2020-10-04 15:12:31.895 11918-13009/com.englishdreaming.appily I/MediaCodec: (0x7308701a00) release
2020-10-04 15:12:31.906 11918-11918/com.englishdreaming.appily D/EventLogger: decoderDisabled [1.08, 0.76, window=0, period=0, audio]
2020-10-04 15:12:31.908 11918-11918/com.englishdreaming.appily D/EventLogger: mediaPeriodReleased [1.08, 0.76, window=0, period=0]

Stack trace from Samsung S4 running Android 5.0.1

10-04 15:20:25.050 8358-8358/com.englishdreaming.appily D/SpellingActivity: initExoplayer:    CALLED
10-04 15:20:25.050 8358-8358/com.englishdreaming.appily I/System.out:    mUris.SIZE is..  10   and POSITION is...   0
10-04 15:20:25.070 8358-8358/com.englishdreaming.appily I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.exoplayer2.video.MediaCodecVideoRenderer$OnFrameRenderedListenerV23>
10-04 15:20:25.080 8358-8358/com.englishdreaming.appily I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.exoplayer2.video.MediaCodecVideoRenderer$OnFrameRenderedListenerV23>
10-04 15:20:25.080 8358-8358/com.englishdreaming.appily I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.exoplayer2.video.MediaCodecVideoRenderer$OnFrameRenderedListenerV23>
10-04 15:20:25.090 8358-8358/com.englishdreaming.appily I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.exoplayer2.video.MediaCodecVideoRenderer$OnFrameRenderedListenerV23>
10-04 15:20:25.090 8358-8358/com.englishdreaming.appily I/art: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.exoplayer2.video.MediaCodecVideoRenderer$OnFrameRenderedListenerV23>
10-04 15:20:25.100 8358-8358/com.englishdreaming.appily I/ExoPlayerImpl: Init 3dfb35fd [ExoPlayerLib/2.8.4] [jflte, GT-I9505, samsung, 21]
10-04 15:20:25.120 8358-8358/com.englishdreaming.appily D/EventLogger: state [0.00, 0.00, window=0, true, BUFFERING]
10-04 15:20:25.150 8358-8358/com.englishdreaming.appily D/Constraints: getView: CALLED
10-04 15:20:25.200 8358-8358/com.englishdreaming.appily D/Constraints: getView: CALLED
10-04 15:20:25.220 8358-8358/com.englishdreaming.appily D/Constraints: getView: CALLED
10-04 15:20:25.220 8358-8358/com.englishdreaming.appily D/Constraints: getView: CALLED
10-04 15:20:25.230 8358-8358/com.englishdreaming.appily D/Constraints: getView: CALLED
10-04 15:20:25.250 8358-8625/com.englishdreaming.appily W/AudioCapabilities: Unsupported mime audio/mpeg-L1
10-04 15:20:25.250 8358-8625/com.englishdreaming.appily W/AudioCapabilities: Unsupported mime audio/mpeg-L2
10-04 15:20:25.250 8358-8625/com.englishdreaming.appily W/AudioCapabilities: Unsupported mime audio/x-ms-wma
10-04 15:20:25.260 8358-8625/com.englishdreaming.appily W/AudioCapabilities: Unsupported mime audio/x-ima
10-04 15:20:25.260 8358-8625/com.englishdreaming.appily W/AudioCapabilities: Unsupported mime audio/qcelp
10-04 15:20:25.260 8358-8625/com.englishdreaming.appily W/AudioCapabilities: Unsupported mime audio/evrc
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger: timelineChanged [0.15, 0.00, window=0, periodCount=1, windowCount=1, reason=PREPARED
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger:   period [?]
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger:   window [?, false, false]
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger: ]
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger: mediaPeriodCreated [0.15, 0.00, window=0, period=0]
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger: loading [0.15, 0.00, window=0, period=0, true]
10-04 15:20:25.270 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/wvc1
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger: timelineChanged [0.16, 0.00, window=0, period=0, periodCount=1, windowCount=1, reason=DYNAMIC
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger:   period [0.91]
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger:   window [0.91, true, false]
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger: ]
10-04 15:20:25.280 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/x-ms-wmv
10-04 15:20:25.280 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es
10-04 15:20:25.280 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/wvc1
10-04 15:20:25.290 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/x-ms-wmv
10-04 15:20:25.290 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/x-ms-wmv7
10-04 15:20:25.290 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/x-ms-wmv8
10-04 15:20:25.290 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/mp43
10-04 15:20:25.300 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/sorenson
10-04 15:20:25.300 8358-8625/com.englishdreaming.appily W/VideoCapabilities: Unsupported mime video/mp4v-esdp
10-04 15:20:25.320 8358-8625/com.englishdreaming.appily I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
10-04 15:20:25.340 8358-8625/com.englishdreaming.appily W/AudioCapabilities: Unsupported mime audio/ac3
10-04 15:20:25.350 8358-8625/com.englishdreaming.appily I/ACodec:  [] Now uninitialized
10-04 15:20:25.350 8358-8636/com.englishdreaming.appily I/OMXClient: Using client-side OMX mux.
10-04 15:20:25.360 8358-8358/com.englishdreaming.appily D/EventLogger: decoderEnabled [0.24, 0.00, window=0, period=0, audio]
10-04 15:20:25.360 8358-8358/com.englishdreaming.appily D/EventLogger: tracksChanged [0.24, 0.00, window=0, period=0, []]
10-04 15:20:25.360 8358-8358/com.englishdreaming.appily D/EventLogger: mediaPeriodReadingStarted [0.24, 0.00, window=0, period=0]
10-04 15:20:25.360 8358-8636/com.englishdreaming.appily I/ACodec: [OMX.SEC.mp3.dec] Now Loaded
10-04 15:20:25.360 8358-8636/com.englishdreaming.appily E/ACodec: onConfigureComponent mime.c_str() = audio/mpeg
10-04 15:20:25.370 8358-8636/com.englishdreaming.appily I/ACodec: [OMX.SEC.mp3.dec] Now Loaded->Idle
10-04 15:20:25.380 8358-8358/com.englishdreaming.appily D/EventLogger: decoderInitialized [0.26, 0.00, window=0, period=0, audio, OMX.SEC.mp3.dec]
10-04 15:20:25.380 8358-8358/com.englishdreaming.appily D/EventLogger: decoderInputFormatChanged [0.26, 0.00, window=0, period=0, audio, id=null, mimeType=audio/mpeg, channels=2, sample_rate=44100]
10-04 15:20:25.380 8358-8358/com.englishdreaming.appily D/EventLogger: loading [0.26, 0.00, window=0, period=0, false]
10-04 15:20:25.380 8358-8636/com.englishdreaming.appily I/ACodec: [OMX.SEC.mp3.dec] Now Idle->Executing
10-04 15:20:25.380 8358-8358/com.englishdreaming.appily D/EventLogger: state [0.26, 0.00, window=0, period=0, true, READY]
10-04 15:20:25.380 8358-8636/com.englishdreaming.appily I/ACodec: [OMX.SEC.mp3.dec] Now Executing
10-04 15:20:25.390 8358-8358/com.englishdreaming.appily D/EventLogger: downstreamFormatChanged [0.27, 0.00, window=0, period=0, id=null, mimeType=audio/mpeg, channels=2, sample_rate=44100]
10-04 15:20:25.420 8358-8625/com.englishdreaming.appily E/AudioTrack: AudioTrack::set : Exit
10-04 15:20:25.420 8358-8358/com.englishdreaming.appily D/EventLogger: audioSessionId [0.31, 0.00, window=0, period=0, 944]
10-04 15:20:25.901 8358-8410/com.englishdreaming.appily V/FA: Inactivity, disconnecting from the service
10-04 15:20:25.911 8358-8358/com.englishdreaming.appily V/FA: onUnbind called for intent. action: com.google.android.gms.measurement.START
10-04 15:20:25.911 8358-8358/com.englishdreaming.appily V/FA: Local AppMeasurementService is shutting down
10-04 15:20:26.481 8358-8358/com.englishdreaming.appily D/EventLogger: state [1.37, 0.92, window=0, period=0, true, ENDED]
10-04 15:20:26.481 8358-8358/com.englishdreaming.appily I/ExoPlayerImpl: Release 3dfb35fd [ExoPlayerLib/2.8.4] [jflte, GT-I9505, samsung, 21] [goog.exo.core]
10-04 15:20:26.491 8358-8636/com.englishdreaming.appily I/ACodec: [OMX.SEC.mp3.dec] Now Executing->Idle
10-04 15:20:26.501 8358-8636/com.englishdreaming.appily I/ACodec: [OMX.SEC.mp3.dec] Now Idle->Loaded
10-04 15:20:26.501 8358-8636/com.englishdreaming.appily I/ACodec: [OMX.SEC.mp3.dec] Now Loaded
10-04 15:20:26.511 8358-8636/com.englishdreaming.appily I/ACodec:  [OMX.SEC.mp3.dec] Now uninitialized
10-04 15:20:26.531 8358-8358/com.englishdreaming.appily D/EventLogger: decoderDisabled [1.41, 0.92, window=0, period=0, audio]
10-04 15:20:26.531 8358-8358/com.englishdreaming.appily D/EventLogger: mediaPeriodReleased [1.41, 0.92, window=0, period=0]
audio
android-5.0-lollipop
exoplayer2.x
asked on Stack Overflow Oct 5, 2020 by netineti

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0