У меня есть FullScreen Активность для воспроизведения видео, Все идет хорошо, пока я не коснусь экрана, чтобы просмотреть System Ui и Media Controller, но MediaController отстает от NavigationBar и его очень мужественный,MediaController отстает от NavigationBar в FullScreen Video Activity
смотрите эти изображения, чтобы понять проблему:
Device1 - and MediaController Visible
и повторно мои коды: MyActivity:
public class ActivityPlayVideo4 extends Activity{
public static final String KEY_VIDEO_URL = "videoUrl";
String url;
ProgressView pvLoading;
private static final boolean AUTO_HIDE = true;
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
private static final boolean TOGGLE_ON_CLICK = true;
private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
private SystemUiHider mSystemUiHider;
private VideoView mVideoView;
private MediaController mMediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
setContentView(R.layout.activity_video_playing);
try {
url = getIntent().getExtras().getString(KEY_VIDEO_URL);
} catch (Exception e) {
url = "";
}
mVideoView = (VideoView) findViewById(R.id.videoView);
// Set up an instance of SystemUiHider to control the system UI for
// this activity.
mSystemUiHider = SystemUiHider.getInstance(this, mVideoView, HIDER_FLAGS);
mSystemUiHider.setup();
mSystemUiHider
.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void onVisibilityChange(boolean visible) {
if (visible && AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
}
});
mVideoView.setOnCompletionListener(new PlayerOnCompleteVideo());
mMediaController = new MediaController(this,false);
mMediaController.setMediaPlayer(mVideoView);
mVideoView.setMediaController(mMediaController);
mVideoView.requestFocus();
pvLoading = (ProgressView) findViewById(R.id.pv_loading);
pvLoading.setVisibility(View.VISIBLE);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
pvLoading.setVisibility(View.GONE);
}
});
playVideo();
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
delayedHide(100);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
Handler mHideHandler = new Handler();
Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
mSystemUiHider.hide();
}
};
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
private class PlayerOnCompleteVideo implements MediaPlayer.OnCompletionListener {
@Override
public void onCompletion(MediaPlayer mp) {
mVideoView.stopPlayback();
playVideo();
}
}
private void playVideo() {
mVideoView.setVideoURI(Uri.parse(url));
mVideoView.start();
}
}
и мой файл Layout (activity_video_playing.xml):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".view.activity.ActivityPlayVideo4">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
>
<VideoView android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true"
android:layout_centerInParent="true"
/>
<com.rey.material.widget.ProgressView
android:id="@+id/pv_loading"
android:layout_width="48dp"
android:layout_height="48dp"
app:pv_autostart="true"
app:pv_circular="true"
app:pv_progressStyle="@style/AppProgressStyle"
app:pv_progressMode="indeterminate"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:visibility="gone"
/>
</RelativeLayout>
</FrameLayout>
Любой человек может мне помочь?!?!?
вы можете скрыть нижнюю Панель навигации см .. https://developer.android.com/training/system-ui/immersive.html –
я знаю, но я хочу видеть NavigationBar и MediaController вместе –
тогда просто не скрывать навигационную панель удалить его код –