在视频屏幕中的垂直线显示器VideoView中播放视频时出现问题,以下代码在Samsung Galaxy TabPro中正常工作,但在Android TV智能盒中运行时,垂直线显示在视频屏幕右侧。 / p>
activity_video_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<VideoView
android:id="@+id/video_activity_videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@color/black" />
<ProgressBar
android:id="@+id/video_activity_progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
VideoActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_layout);
mVideoView = (VideoView) findViewById(R.id.video_activity_videoView);
mMc = new CustomMediaController(this);
mMc.setFocusable(true);
mVideoView.setMediaController(mMc);
mVideoView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (mMc != null) mMc.show(5000);
} else {
if (mMc != null) mMc.hide();
}
}
});
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
if (Constant.DEBUG) Log.d(TAG, "Duration = " + mVideoView.getDuration()
+ ", Type = " + mType + ", mHasPermission = " + mHasPermission);
if (mTimer == null && mHasPermission == false) {
mTimer = new Timer(true);
mTimer.schedule(new timerTask(), 1000, 1000);
}
mp.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
if (Constant.DEBUG) Log.d(TAG, "percent = " + percent);
if (mIsReady == false) {
mIsReady = true;
mVideoView.setBackgroundColor(getResources().getColor(R.color.none));
ProgressBar progressBar = (ProgressBar) findViewById(R.id.video_activity_progressBar);
if (progressBar.getVisibility() != View.GONE) progressBar.setVisibility(View.GONE);
}
}
});
}
});
mType = getIntent().getIntExtra("type", Constant.PRG_TYPE_CHARGE);
mHasPermission = getIntent().getBooleanExtra("permission", true);
mId = getIntent().getStringExtra("id");
String playTime = getIntent().getStringExtra("play_time");
if (playTime != null) {
mPlayTime = Integer.valueOf(playTime) * 1000;
Log.d(TAG, "mPlayTime = " + mPlayTime);
}
mString = getIntent().getStringExtra("url");
if (mString == null) {
finish();
} else {
mVideoView.setVideoURI(Uri.parse(mString));
if (mPlayTime != 0) {
showContinueDialog();
} else {
mVideoView.requestFocus();
mVideoView.start();
}
}
}
任何帮助将不胜感激。谢谢。