Prevented videooverlay from hiding while the user is touching the
video overlay
This commit is contained in:
parent
3bcd77c0d2
commit
add5ce69d3
|
@ -43,7 +43,7 @@ import de.danoeh.antennapod.util.MediaPlayerError;
|
|||
import de.danoeh.antennapod.util.StorageUtils;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
|
||||
|
||||
public abstract class MediaplayerActivity extends SherlockFragmentActivity {
|
||||
public abstract class MediaplayerActivity extends SherlockFragmentActivity implements OnSeekBarChangeListener{
|
||||
private static final String TAG = "MediaplayerActivity";
|
||||
|
||||
static final int DEFAULT_SEEK_DELTA = 30000;
|
||||
|
@ -471,39 +471,7 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity {
|
|||
|
||||
// SEEKBAR SETUP
|
||||
|
||||
sbPosition.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
int duration;
|
||||
float prog;
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||
boolean fromUser) {
|
||||
if (fromUser && PlaybackService.isRunning) {
|
||||
prog = progress / ((float) seekBar.getMax());
|
||||
duration = playbackService.getPlayer().getDuration();
|
||||
txtvPosition.setText(Converter
|
||||
.getDurationStringLong((int) (prog * duration)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// interrupt position Observer, restart later
|
||||
if (positionObserver != null) {
|
||||
positionObserver.cancel(true);
|
||||
positionObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
if (PlaybackService.isRunning) {
|
||||
playbackService.seek((int) (prog * duration));
|
||||
setupPositionObserver();
|
||||
}
|
||||
}
|
||||
});
|
||||
sbPosition.setOnSeekBarChangeListener(this);
|
||||
|
||||
// BUTTON SETUP
|
||||
|
||||
|
@ -606,5 +574,38 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// OnSeekbarChangeListener
|
||||
private int duration;
|
||||
private float prog;
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||
boolean fromUser) {
|
||||
if (fromUser && PlaybackService.isRunning) {
|
||||
prog = progress / ((float) seekBar.getMax());
|
||||
duration = playbackService.getPlayer().getDuration();
|
||||
txtvPosition.setText(Converter
|
||||
.getDurationStringLong((int) (prog * duration)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// interrupt position Observer, restart later
|
||||
if (positionObserver != null) {
|
||||
positionObserver.cancel(true);
|
||||
positionObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
if (PlaybackService.isRunning) {
|
||||
playbackService.seek((int) (prog * duration));
|
||||
setupPositionObserver();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,9 +12,11 @@ import android.util.Log;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.VideoView;
|
||||
|
||||
public class VideoplayerActivity extends MediaplayerActivity implements
|
||||
|
@ -54,6 +56,7 @@ public class VideoplayerActivity extends MediaplayerActivity implements
|
|||
videoview.getHolder().addCallback(this);
|
||||
videoview.setOnClickListener(playbuttonListener);
|
||||
videoview.setOnTouchListener(onVideoviewTouched);
|
||||
|
||||
setupVideoControlsToggler();
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
@ -100,7 +103,7 @@ public class VideoplayerActivity extends MediaplayerActivity implements
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
void setupVideoControlsToggler() {
|
||||
if (videoControlsToggler != null) {
|
||||
|
@ -202,4 +205,20 @@ public class VideoplayerActivity extends MediaplayerActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
super.onStartTrackingTouch(seekBar);
|
||||
if (videoControlsToggler != null) {
|
||||
videoControlsToggler.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
super.onStopTrackingTouch(seekBar);
|
||||
setupVideoControlsToggler();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue