如何处理exoplayer库引发的IllegalStateException

时间:2018-06-19 20:31:39

标签: android exoplayer

我正在开发一个应用程序,即时通讯使用Exoplayer库替代android的videoview。 exoplayer抛出这些警告

06-20 01:39:22.218 22768-22768/<my_package_name>W/MessageQueue: Handler (android.os.Handler) {4e8469a} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {4e8469a} sending message to a Handler on a dead thread
    at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
    at android.os.Handler.enqueueMessage(Handler.java:643)
    at android.os.Handler.sendMessageAtTime(Handler.java:612)
    at android.os.Handler.sendMessageDelayed(Handler.java:582)
    at android.os.Handler.sendMessage(Handler.java:519)
    at android.os.Message.sendToTarget(Message.java:416)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.seekTo(ExoPlayerImplInternal.java:195)
    at com.google.android.exoplayer2.ExoPlayerImpl.seekTo(ExoPlayerImpl.java:294)
    at com.google.android.exoplayer2.ExoPlayerImpl.seekTo(ExoPlayerImpl.java:257)
    at com.devbrackets.android.exomedia.core.exoplayer.ExoMediaPlayer.seekTo(ExoMediaPlayer.java:421)
    at com.devbrackets.android.exomedia.core.exoplayer.ExoMediaPlayer.seekTo(ExoMediaPlayer.java:380)
    at com.devbrackets.android.exomedia.core.video.exo.ExoVideoDelegate.setVideoUri(ExoVideoDelegate.java:67)
    at com.devbrackets.android.exomedia.core.video.exo.ExoVideoDelegate.setVideoUri(ExoVideoDelegate.java:61)
    at com.devbrackets.android.exomedia.core.video.exo.ExoSurfaceVideoView.setVideoUri(ExoSurfaceVideoView.java:72)
    at com.devbrackets.android.exomedia.ui.widget.VideoView.setVideoURI(VideoView.java:295)
    at com.devbrackets.android.exomedia.ui.widget.VideoView.setVideoPath(VideoView.java:324)
    at <my_package_name>.Fragments.HomeFragment.prepareExoVideoRelatedStuff_callback(HomeFragment.java:572)
    at <my_package_name>.Adapters.PostsAdapter$ViewHolder.bindPost(PostsAdapter.java:345)
    at <my_package_name>.Adapters.PostsAdapter.onBindViewHolder(PostsAdapter.java:112)
    at <my_package_name>.Adapters.PostsAdapter.onBindViewHolder(PostsAdapter.java:68)
    at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6673)
    at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6714)
    at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5647)
    at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5913)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)
    at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232)
    at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559)
    at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)
    at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)
    at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812)
    at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3225)
    at android.view.View.measure(View.java:19759)
    at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1210)
    at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1550)
    at android.view.View.measure(View.java:19759)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:19759)
    at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1617)
    at android.view.View.measure(View.java:19759)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
    at android.view.View.measure(View.java:19759)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
    at android.view.View.measure(View.java:19759)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:19759)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
    at android.view.View.measure(View.java:19759)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6124)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at com.android.internal.policy.DecorView.onMeasure(DecorView.java:687)
    at android.view.View.measure(View.java:19759)
    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2283)
    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1370)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1258)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6348)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
    at android.view.Choreographer.doCallbacks(Choreographer.java:683)
    at android.view.Choreographer.doFrame(Choreographer.java:619)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6123)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

当我从屏幕上滚动视频时,直到调用onPause或onStop并且这些警告显示在Logcat中之后,视频才会再次显示(显示黑屏)。 我已经尝试调试,但到目前为止没有任何发现。请帮助我坚持这一点。  继承人的xml

<com.devbrackets.android.exomedia.ui.widget.VideoView
                    android:id="@+id/video_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"

                    android:clickable="false"
                    app:useDefaultControls="true" />

和Java代码

        videoView.setVideoPath(post.getPostVideo());


    videoView.setOnPreparedListener(new OnPreparedListener() {
        @Override
        public void onPrepared() {
            videoView.start();
        }
    });

我关注了exoplayer GitHub页面Exoplayer GitHub page

0 个答案:

没有答案