{"action":"created","issue":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/6105","repository_url":"https://api.github.com/repos/google/ExoPlayer","labels_url":"https://api.github.com/repos/google/ExoPlayer/issues/6105/labels{/name}","comments_url":"https://api.github.com/repos/google/ExoPlayer/issues/6105/comments","events_url":"https://api.github.com/repos/google/ExoPlayer/issues/6105/events","html_url":"https://github.com/google/ExoPlayer/issues/6105","id":461840716,"node_id":"MDU6SXNzdWU0NjE4NDA3MTY=","number":6105,"title":"MediaCodecRenderer.getOutputBuffer crash","user":{"login":"imliujun","id":9779970,"node_id":"MDQ6VXNlcjk3Nzk5NzA=","avatar_url":"https://avatars2.githubusercontent.com/u/9779970?v=4","gravatar_id":"","url":"https://api.github.com/users/imliujun","html_url":"https://github.com/imliujun","followers_url":"https://api.github.com/users/imliujun/followers","following_url":"https://api.github.com/users/imliujun/following{/other_user}","gists_url":"https://api.github.com/users/imliujun/gists{/gist_id}","starred_url":"https://api.github.com/users/imliujun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imliujun/subscriptions","organizations_url":"https://api.github.com/users/imliujun/orgs","repos_url":"https://api.github.com/users/imliujun/repos","events_url":"https://api.github.com/users/imliujun/events{/privacy}","received_events_url":"https://api.github.com/users/imliujun/received_events","type":"User","site_admin":false},"labels":[{"id":106814989,"node_id":"MDU6TGFiZWwxMDY4MTQ5ODk=","url":"https://api.github.com/repos/google/ExoPlayer/labels/bug","name":"bug","color":"fc2929","default":true},{"id":214717009,"node_id":"MDU6TGFiZWwyMTQ3MTcwMDk=","url":"https://api.github.com/repos/google/ExoPlayer/labels/need%20more%20info","name":"need more info","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":{"login":"andrewlewis","id":107897,"node_id":"MDQ6VXNlcjEwNzg5Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/107897?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewlewis","html_url":"https://github.com/andrewlewis","followers_url":"https://api.github.com/users/andrewlewis/followers","following_url":"https://api.github.com/users/andrewlewis/following{/other_user}","gists_url":"https://api.github.com/users/andrewlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewlewis/subscriptions","organizations_url":"https://api.github.com/users/andrewlewis/orgs","repos_url":"https://api.github.com/users/andrewlewis/repos","events_url":"https://api.github.com/users/andrewlewis/events{/privacy}","received_events_url":"https://api.github.com/users/andrewlewis/received_events","type":"User","site_admin":false},"assignees":[{"login":"andrewlewis","id":107897,"node_id":"MDQ6VXNlcjEwNzg5Nw==","avatar_url":"https://avatars3.githubusercontent.com/u/107897?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewlewis","html_url":"https://github.com/andrewlewis","followers_url":"https://api.github.com/users/andrewlewis/followers","following_url":"https://api.github.com/users/andrewlewis/following{/other_user}","gists_url":"https://api.github.com/users/andrewlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewlewis/subscriptions","organizations_url":"https://api.github.com/users/andrewlewis/orgs","repos_url":"https://api.github.com/users/andrewlewis/repos","events_url":"https://api.github.com/users/andrewlewis/events{/privacy}","received_events_url":"https://api.github.com/users/andrewlewis/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2019-06-28T03:42:13Z","updated_at":"2019-07-02T03:37:28Z","closed_at":null,"author_association":"NONE","body":"Don't crash if this exception occurs\r\n\r\n> exoplayerVersion        : \"2.10.2\"\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/9779970/60314513-71cdcb80-9995-11e9-8894-8ff24dff7d34.png)\r\n\r\n**Device(s) and version(s)**\r\n![image](https://user-images.githubusercontent.com/9779970/60315221-40a2ca80-9998-11e9-88ab-1522aef57de5.png)\r\n"},"comment":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/comments/507505151","html_url":"https://github.com/google/ExoPlayer/issues/6105#issuecomment-507505151","issue_url":"https://api.github.com/repos/google/ExoPlayer/issues/6105","id":507505151,"node_id":"MDEyOklzc3VlQ29tbWVudDUwNzUwNTE1MQ==","user":{"login":"imliujun","id":9779970,"node_id":"MDQ6VXNlcjk3Nzk5NzA=","avatar_url":"https://avatars2.githubusercontent.com/u/9779970?v=4","gravatar_id":"","url":"https://api.github.com/users/imliujun","html_url":"https://github.com/imliujun","followers_url":"https://api.github.com/users/imliujun/followers","following_url":"https://api.github.com/users/imliujun/following{/other_user}","gists_url":"https://api.github.com/users/imliujun/gists{/gist_id}","starred_url":"https://api.github.com/users/imliujun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imliujun/subscriptions","organizations_url":"https://api.github.com/users/imliujun/orgs","repos_url":"https://api.github.com/users/imliujun/repos","events_url":"https://api.github.com/users/imliujun/events{/privacy}","received_events_url":"https://api.github.com/users/imliujun/received_events","type":"User","site_admin":false},"created_at":"2019-07-02T03:37:28Z","updated_at":"2019-07-02T03:37:28Z","author_association":"NONE","body":"@andrewlewis \r\n1. only seen this via remote crash reports\r\n2. this error  in 2.10.2、2.10.1、2.9.6 and more\r\n3. No code modified\r\n\r\n**My usage：**\r\nIn the recyclerview, the video Item plays automatically when it is displayed, and uses DownloadManager\r\n\r\nUsed https://github.com/lipangit/JiaoZiVideoPlayer\r\n\r\nPlay the kernel code as:\r\n\r\n```java\r\npublic class JZExoPlayer extends JZMediaInterface implements Player.EventListener, VideoListener {\r\n    @Nullable\r\n    private SimpleExoPlayer simpleExoPlayer;\r\n    private Handler mainHandler;\r\n    private Runnable callback;\r\n    private MediaSource videoSource;\r\n    private long previousSeek = 0;\r\n    private boolean preventRepetition = true;\r\n    \r\n    \r\n    @Override\r\n    public void start() {\r\n        //        Timber.e(\"start\");\r\n        if (simpleExoPlayer != null) {\r\n            simpleExoPlayer.setPlayWhenReady(true);\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void prepare() {\r\n        //        Timber.e(\"prepare\");\r\n        mainHandler = new Handler(Looper.getMainLooper());\r\n        Jzvd currentJzvd = JzvdMgr.getCurrentJzvd();\r\n        Context context;\r\n        if (currentJzvd != null) {\r\n            context = currentJzvd.getContext();\r\n        } else {\r\n            context = Utils.getApp();\r\n        }\r\n        \r\n        \r\n        TrackSelector trackSelector = new DefaultTrackSelector();\r\n        LoadControl loadControl = new DefaultLoadControl.Builder().setAllocator(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE)).createDefaultLoadControl();\r\n        \r\n        // 2. Create the player\r\n        \r\n        RenderersFactory renderersFactory = new DefaultRenderersFactory(context);\r\n        simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(context, renderersFactory, trackSelector, loadControl, null, Looper.getMainLooper());\r\n        String currUrl = jzDataSource.getCurrentUrl().toString();\r\n        if (TextUtils.isEmpty(currUrl)) {\r\n            return;\r\n        }\r\n        //缓存\r\n        if (ExoDownload.getInstance().isOpenCache()) {\r\n            ExoDownload.getInstance().getDownloadTracker().toggleDownload(EncryptUtils.encryptMD5ToString(currUrl), Uri.parse(currUrl), \"\", ExoDownload.getInstance()\r\n                .buildRenderersFactory(false));\r\n        }\r\n        DataSource.Factory dataSourceFactory = ExoDownload.getInstance().buildDataSourceFactory(Utils.getApp());\r\n        videoSource = buildMediaSource(dataSourceFactory, Uri.parse(currUrl), null);\r\n        \r\n        simpleExoPlayer.addVideoListener(this);\r\n        \r\n        simpleExoPlayer.addListener(this);\r\n        simpleExoPlayer.setRepeatMode(Player.REPEAT_MODE_ALL);\r\n        simpleExoPlayer.prepare(videoSource);\r\n        simpleExoPlayer.setPlayWhenReady(true);\r\n        callback = new onBufferingUpdate();\r\n    }\r\n    \r\n    @Override\r\n    public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {\r\n        //        Timber.e(\"onVideoSizeChanged\");\r\n        JZMediaManager.instance().currentVideoWidth = width;\r\n        JZMediaManager.instance().currentVideoHeight = height;\r\n        JZMediaManager.instance().mainThreadHandler.post(() -> {\r\n            if (JzvdMgr.getCurrentJzvd() != null) {\r\n                JzvdMgr.getCurrentJzvd().onVideoSizeChanged();\r\n            }\r\n        });\r\n    }\r\n    \r\n    private MediaSource buildMediaSource(DataSource.Factory dataSourceFactory, Uri uri, @Nullable String overrideExtension) {\r\n        @C.ContentType int type = Util.inferContentType(uri, overrideExtension);\r\n        switch (type) {\r\n            case C.TYPE_DASH:\r\n                return new DashMediaSource.Factory(dataSourceFactory)\r\n                    .setManifestParser(\r\n                        new FilteringManifestParser<>(new DashManifestParser(), getOfflineStreamKeys(uri)))\r\n                    .createMediaSource(uri);\r\n            case C.TYPE_SS:\r\n                return new SsMediaSource.Factory(dataSourceFactory)\r\n                    .setManifestParser(\r\n                        new FilteringManifestParser<>(new SsManifestParser(), getOfflineStreamKeys(uri)))\r\n                    .createMediaSource(uri);\r\n            case C.TYPE_HLS:\r\n                return new HlsMediaSource.Factory(dataSourceFactory)\r\n                    .setPlaylistParserFactory(\r\n                        new DefaultHlsPlaylistParserFactory())\r\n                    .createMediaSource(uri);\r\n            case C.TYPE_OTHER:\r\n                boolean isRtmpSource = uri.toString().toLowerCase().startsWith(\"rtmp://\");\r\n                boolean isFlacSource = uri.toString().toLowerCase().endsWith(\".flac\");\r\n                if (isFlacSource) {\r\n                    DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();\r\n                    return new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory,\r\n                        null, null);\r\n                } else {\r\n                    return new ExtractorMediaSource\r\n                        .Factory(isRtmpSource ? new RtmpDataSourceFactory() : dataSourceFactory)\r\n                        .createMediaSource(uri);\r\n                }\r\n            default: {\r\n                throw new IllegalStateException(\"Unsupported type: \" + type);\r\n            }\r\n        }\r\n    }\r\n    \r\n    private List<StreamKey> getOfflineStreamKeys(Uri uri) {\r\n        return ExoDownload.getInstance().getDownloadTracker().getDownloadRequest(uri).streamKeys;\r\n    }\r\n    \r\n    @Override\r\n    public void onRenderedFirstFrame() {\r\n        //        Timber.e(\"onRenderedFirstFrame\");\r\n    }\r\n    \r\n    private class onBufferingUpdate implements Runnable {\r\n        @Override\r\n        public void run() {\r\n            final int percent;\r\n            if (simpleExoPlayer != null) {\r\n                percent = simpleExoPlayer.getBufferedPercentage();\r\n            } else {\r\n                percent = 0;\r\n            }\r\n            JZMediaManager.instance().mainThreadHandler.post(() -> {\r\n                if (JzvdMgr.getCurrentJzvd() != null) {\r\n                    JzvdMgr.getCurrentJzvd().setBufferProgress(percent);\r\n                }\r\n            });\r\n            if (percent < 100) {\r\n                mainHandler.postDelayed(callback, 300);\r\n            } else {\r\n                mainHandler.removeCallbacks(callback);\r\n            }\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void pause() {\r\n        //        Timber.e(\"pause\");\r\n        if (simpleExoPlayer != null) {\r\n            simpleExoPlayer.setPlayWhenReady(false);\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public boolean isPlaying() {\r\n        //        Timber.e(\"isPlaying\");\r\n        if (simpleExoPlayer != null) {\r\n            return simpleExoPlayer.getPlayWhenReady();\r\n        } else {\r\n            return false;\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void seekTo(long time) {\r\n        //        Timber.e(\"seekTo\");\r\n        Jzvd currentJzvd = JzvdMgr.getCurrentJzvd();\r\n        if (currentJzvd == null) {\r\n            return;\r\n        }\r\n        if (time != previousSeek) {\r\n            if (simpleExoPlayer != null) {\r\n                simpleExoPlayer.seekTo(time);\r\n            }\r\n            previousSeek = time;\r\n            currentJzvd.seekToInAdvance = time;\r\n        } else {\r\n            if (simpleExoPlayer != null && time == simpleExoPlayer.getDuration() && preventRepetition) {\r\n                preventRepetition = false;\r\n                simpleExoPlayer.seekTo(time);\r\n                previousSeek = time;\r\n                currentJzvd.seekToInAdvance = time;\r\n                preventRepetition = true;\r\n            }\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void release() {\r\n        //        Timber.e(\"release\");\r\n        videoSource = null;\r\n        if (simpleExoPlayer != null) {\r\n            simpleExoPlayer.release();\r\n        }\r\n        if (mainHandler != null) {\r\n            mainHandler.removeCallbacks(callback);\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public long getCurrentPosition() {\r\n        //        Timber.e(\"getCurrentPosition\");\r\n        if (simpleExoPlayer != null) {\r\n            return simpleExoPlayer.getCurrentPosition();\r\n        } else {\r\n            return 0;\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public long getDuration() {\r\n        //        Timber.e(\"getDuration\");\r\n        if (simpleExoPlayer != null) {\r\n            return simpleExoPlayer.getDuration();\r\n        } else {\r\n            return 0;\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void setSurface(Surface surface) {\r\n        //        Timber.e(\"setSurface\");\r\n        if (simpleExoPlayer != null) {\r\n            simpleExoPlayer.setVideoSurface(surface);\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void setVolume(float leftVolume, float rightVolume) {\r\n        if (simpleExoPlayer != null) {\r\n            simpleExoPlayer.setVolume(leftVolume);\r\n            simpleExoPlayer.setVolume(rightVolume);\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void setSpeed(float speed) {\r\n        if (simpleExoPlayer != null) {\r\n            PlaybackParameters playbackParameters = new PlaybackParameters(speed, 1.0F);\r\n            simpleExoPlayer.setPlaybackParameters(playbackParameters);\r\n        }\r\n    }\r\n    \r\n    @Override\r\n    public void onTimelineChanged(final Timeline timeline, Object manifest, final int reason) {\r\n        //        JZMediaManager.instance().mainThreadHandler.post(() -> {\r\n        //                if (reason == 0) {\r\n        //\r\n        //                    JzvdMgr.getCurrentJzvd().onInfo(reason, timeline.getPeriodCount());\r\n        //                }\r\n        //        });\r\n    }\r\n    \r\n    @Override\r\n    public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {\r\n    \r\n    }\r\n    \r\n    @Override\r\n    public void onLoadingChanged(boolean isLoading) {\r\n        //        Timber.e(\"onLoadingChanged isLoading:%s\", isLoading);\r\n    }\r\n    \r\n    @Override\r\n    public void onPlayerStateChanged(final boolean playWhenReady, final int playbackState) {\r\n        //        Timber.e(\"onPlayerStateChanged: %s /ready=%s\", playbackState, String.valueOf(playWhenReady));\r\n        JZMediaManager.instance().mainThreadHandler.post(() -> {\r\n            if (JzvdMgr.getCurrentJzvd() != null) {\r\n                switch (playbackState) {\r\n                    case Player.STATE_IDLE: {\r\n                    }\r\n                    break;\r\n                    case Player.STATE_BUFFERING: {\r\n                        mainHandler.post(callback);\r\n                    }\r\n                    break;\r\n                    case Player.STATE_READY: {\r\n                        if (playWhenReady) {\r\n                            JzvdMgr.getCurrentJzvd().onPrepared();\r\n                        } else {\r\n                        }\r\n                    }\r\n                    break;\r\n                    case Player.STATE_ENDED: {\r\n                        JzvdMgr.getCurrentJzvd().onAutoCompletion();\r\n                    }\r\n                    break;\r\n                    default:\r\n                        break;\r\n                }\r\n            }\r\n        });\r\n    }\r\n    \r\n    @Override\r\n    public void onRepeatModeChanged(int repeatMode) {\r\n        //        Timber.e(\"onRepeatModeChanged %s\", repeatMode);\r\n    }\r\n    \r\n    @Override\r\n    public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {\r\n    \r\n    }\r\n    \r\n    @Override\r\n    public void onPlayerError(ExoPlaybackException error) {\r\n        //        Timber.e(\"onPlayerError %s\", error.toString());\r\n        if (videoSource == null) {\r\n            return;\r\n        }\r\n        JZMediaManager.instance().mainThreadHandler.post(() -> {\r\n            if (JzvdMgr.getCurrentJzvd() != null) {\r\n                JzvdMgr.getCurrentJzvd().onError(1000, 1000);\r\n            }\r\n        });\r\n    }\r\n    \r\n    @Override\r\n    public void onPositionDiscontinuity(int reason) {\r\n    \r\n    }\r\n    \r\n    @Override\r\n    public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {\r\n    \r\n    }\r\n    \r\n    @Override\r\n    public void onSeekProcessed() {\r\n        JZMediaManager.instance().mainThreadHandler.post(() -> {\r\n            if (JzvdMgr.getCurrentJzvd() != null) {\r\n                JzvdMgr.getCurrentJzvd().onSeekComplete();\r\n            }\r\n        });\r\n    }\r\n    \r\n}\r\n```\r\n"}}
{"actor":{"display_login":"imliujun"}}