ExoPlayer在Android 5.0设备上不能完全播放音频文件,在Android 9上可以

问题描述

我正在使用Exoplayer播放简短的mp3(语音)文件,并且我的代码在运行Android 9的Moto G6上运行正常,我一直在使用它来开发应用程序。但是在Android 5.0上的Samsung S4上运行它时,每个剪辑的结尾不会播放大约半秒。

我正在使用Exoplayer,因为用户通常可以选择以慢速播放剪辑,并且我知道MediaPlayer在

我要发布我的Exoplayer方法调用后每个设备的堆栈跟踪-我添加一个事件记录器。我不知道为什么5.0设备堆栈跟踪中有行引用视频而其他行没有,但我怀疑行'10 -04 15:20:25.420 8358-8625 / com.englishdreaming.appily E / AudioTrack: AudioTrack :: set:“退出”可能对比我更好地阅读堆栈跟踪的人有所帮助-它采用致命异常的方式进行着色,并且仅在5.0堆栈跟踪中发生。

在开发的早期,我记得在Android 9设备上有一个类似的问题,即音频文件的结尾被切断了,但是我不记得我是如何解决的,或者它是否解决了本身-但现在在9上可以正常使用,但在5.0上却不能。非常感谢您提出有关如何立即修复的任何想法。

    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);
    }

运行Android 9的Moto g6的堆栈跟踪:

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,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,period=0]
2020-10-04 15:12:30.927 11918-11918/com.englishdreaming.appily D/EventLogger: loading [0.10,period=0,true]
2020-10-04 15:12:30.932 11918-11918/com.englishdreaming.appily D/EventLogger: timelineChanged [0.10,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,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,audio]
2020-10-04 15:12:30.934 11918-11918/com.englishdreaming.appily D/EventLogger: tracksChanged [0.11,[]]
2020-10-04 15:12:30.935 11918-11918/com.englishdreaming.appily D/EventLogger: mediaPeriodReadingStarted [0.11,period=0]
2020-10-04 15:12:30.936 11918-11918/com.englishdreaming.appily D/EventLogger: decoderInitialized [0.11,audio,OMX.google.mp3.decoder]
2020-10-04 15:12:30.937 11918-11918/com.englishdreaming.appily D/EventLogger: decoderInputFormatChanged [0.11,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,false]
2020-10-04 15:12:30.939 11918-11918/com.englishdreaming.appily D/EventLogger: state [0.11,READY]
2020-10-04 15:12:30.940 11918-11918/com.englishdreaming.appily D/EventLogger: downstreamFormatChanged [0.11,sample_rate=44100]
2020-10-04 15:12:30.941 11918-11918/com.englishdreaming.appily D/EventLogger: audioSessionId [0.11,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,ENDED]
2020-10-04 15:12:31.882 11918-11918/com.englishdreaming.appily I/ExoPlayerImpl: Release 1bfc9f [ExoPlayerLib/2.8.4] [evert_n,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,audio]
2020-10-04 15:12:31.908 11918-11918/com.englishdreaming.appily D/EventLogger: mediaPeriodReleased [1.08,period=0]

运行Android 5.0.1的Samsung S4的堆栈跟踪

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,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,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]
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,period=0]
10-04 15:20:25.270 8358-8358/com.englishdreaming.appily D/EventLogger: loading [0.15,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,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,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,audio]
10-04 15:20:25.360 8358-8358/com.englishdreaming.appily D/EventLogger: tracksChanged [0.24,[]]
10-04 15:20:25.360 8358-8358/com.englishdreaming.appily D/EventLogger: mediaPeriodReadingStarted [0.24,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,OMX.SEC.mp3.dec]
10-04 15:20:25.380 8358-8358/com.englishdreaming.appily D/EventLogger: decoderInputFormatChanged [0.26,sample_rate=44100]
10-04 15:20:25.380 8358-8358/com.englishdreaming.appily D/EventLogger: loading [0.26,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,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,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,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,ENDED]
10-04 15:20:26.481 8358-8358/com.englishdreaming.appily I/ExoPlayerImpl: Release 3dfb35fd [ExoPlayerLib/2.8.4] [jflte,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,audio]
10-04 15:20:26.531 8358-8358/com.englishdreaming.appily D/EventLogger: mediaPeriodReleased [1.41,period=0]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)