1

如何在android中使用视频视图避免或清除手机屏幕背景?

[1]: ( http://i.stack.imgur.com/0pl9W.png )

View.OnClickListener handleOnClickVideo(final ImageView button1) {
    return new View.OnClickListener() {
        public void onClick(View v) {
            try {

                Constant.database = new MyHelper(getApplicationContext());
                Constant.sqldb = Constant.database.getReadableDatabase();
                imageShowed.setVisibility(View.GONE);
                videoShowed.setVisibility(View.VISIBLE);
                mVideoView.setBackgroundColor(Color.BLACK);
                bar.show();
                int newVideoId = button1.getId();
                Constant.database.getContentValues(newVideoId);
                String getVideo = "https://whootin.s3.amazonaws.com/uploads/upload/21e0b4df-120d-4c9f-ad4a-b475bb844b48/Homemade%20Steak%20Fajitas%20Recipe%20-%20Laura%20Vitale%20-%20Laura%20in%20the%20.mp4?AWSAccessKeyId=AKIAJF5QHW2P5ZLAGVDQ&Signature=EGU5xUP3E8QpkTrG71dr0MvR2hQ%3D&Expires=1381916425";//GetSet.getVideo();
                Log.d("video", getVideo);
                mVideoView.setSoundEffectsEnabled(true);
                mVideoView.setDrawingCacheEnabled(true);
                mediaController.setAnchorView(mVideoView);
                mVideoView.setVideoURI(Uri.parse(getVideo));
                mVideoView.setKeepScreenOn(true);
                mVideoView.setMediaController(mediaController);
                mVideoView.requestFocus();
                mVideoView.setOnPreparedListener(PreparedListener);
                Constant.database.close();

            } catch (Exception e) {
                Log.e(TAG, "error: " + e.getMessage(), e);
                bar.dismiss();
            }
        }
    };
}

我附上了我的代码。

4

1 回答 1

7

您可以设置视频开始之前的可见mVideoView性。GONE

public void onPrepared(MediaPlayer mp) {

    View placeholder = (View) findViewById(R.id.placeholder);

    placeholder.setVisibility(View.GONE);
}

或者你可以像这样ZOrder改变mVideoView

videoView.setZOrderOnTop(true);

参考看这个问题:Android VideoView black screen

于 2013-10-09T11:37:26.733 回答