VideoView black flash before and after playing

前端 未结 14 2181
谎友^
谎友^ 2020-12-09 04:04

I have a VideoView which I want to use to play a movieclip. I use it like this to play it and it works.

VideoView vv = new VideoView(this);
vv.setVideoURI(Ur         


        
相关标签:
14条回答
  • Try this line.This worked for me. if(player!=null)player.release();

    @Override
     protected void onDestroy() {
         super.onDestroy();
             player.pause();
         if(player!=null)player.release();
         player = null;
         videoSurface = null;
         controller = null;
    
     }
    
    0 讨论(0)
  • 2020-12-09 04:45

    My variation on the @tommyd theme:

    Set the drawable to a static video frame, then spam the message queue. After some time, clear the drawable so video frames render. Then, before completion, set the static image back.

        mMovieView.setBackgroundDrawable(bg);
        mMovieView.start();
    
        final int kPollTime= 25;
        mMovieView.postDelayed(new Runnable() {
    
            private final int kStartTransitionInThreshold= 50;
            private final int kStartTransitionOutThreshold= 250;
    
            private boolean mTransitioned= false;
            @Override
            public void run() {
                if (mMovieView.isPlaying()) {
                    if (mMovieView.getCurrentPosition() > kStartTransitionInThreshold && !mTransitioned) {
                        mMovieView.setBackgroundDrawable(null); // clear to video
                        mTransitioned= true;
                    }
    
                    if (mMovieView.getDuration() - mMovieView.getCurrentPosition() < kStartTransitionOutThreshold)
                        mMovieView.setBackgroundDrawable(bg);
                }
    
                mMovieView.postDelayed(this, kPollTime); // come back in a bit and try again
            }
        }, kPollTime);
    
    0 讨论(0)
提交回复
热议问题