@Override
 public void onStartTrackingTouch(SeekBar seekBar) {
   super.onStartTrackingTouch(seekBar);
   if (videoControlsToggler != null) {
     videoControlsToggler.cancel(true);
   }
 }
 @Override
 protected void setScreenOn(boolean enable) {
   super.setScreenOn(enable);
   if (enable) {
     getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   } else {
     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   }
 }
 @Override
 protected void onPause() {
   super.onPause();
   if (videoControlsToggler != null) {
     videoControlsToggler.cancel(true);
   }
   if (controller != null && controller.getStatus() == PlayerStatus.PLAYING) {
     controller.pause();
   }
 }
 @SuppressLint("AppCompatMethod")
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
   supportRequestWindowFeature(
       WindowCompat.FEATURE_ACTION_BAR_OVERLAY); // has to be called before setting layout content
   super.onCreate(savedInstanceState);
   getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0x80000000));
 }
 @Override
 protected void onResume() {
   super.onResume();
   if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_VIEW)) {
     Intent intent = getIntent();
     if (BuildConfig.DEBUG) Log.d(TAG, "Received VIEW intent: " + intent.getData().getPath());
     ExternalMedia media = new ExternalMedia(intent.getData().getPath(), MediaType.VIDEO);
     Intent launchIntent = new Intent(this, PlaybackService.class);
     launchIntent.putExtra(PlaybackService.EXTRA_PLAYABLE, media);
     launchIntent.putExtra(PlaybackService.EXTRA_START_WHEN_PREPARED, true);
     launchIntent.putExtra(PlaybackService.EXTRA_SHOULD_STREAM, false);
     launchIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY, true);
     startService(launchIntent);
   }
 }
  @Override
  protected void setupGUI() {
    super.setupGUI();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    videoOverlay = (LinearLayout) findViewById(R.id.overlay);
    videoview = (AspectRatioVideoView) findViewById(R.id.videoview);
    progressIndicator = (ProgressBar) findViewById(R.id.progressIndicator);
    videoview.getHolder().addCallback(surfaceHolderCallback);
    videoview.setOnTouchListener(onVideoviewTouched);

    if (Build.VERSION.SDK_INT >= 16) {
      videoview.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    }
    if (Build.VERSION.SDK_INT >= 14) {
      videoOverlay.setFitsSystemWindows(true);
    }

    setupVideoControlsToggler();
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }
 @Override
 public void onStopTrackingTouch(SeekBar seekBar) {
   super.onStopTrackingTouch(seekBar);
   setupVideoControlsToggler();
 }