Commit b6c6c1f6 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Video player: Restore 360° navigation

parent 73d218f9
......@@ -249,7 +249,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private boolean mLockBackButton = false;
boolean mWasPaused = false;
private long mSavedTime = -1;
private float mSavedRate = 1.f;
/**
* For uninterrupted switching between audio and video mode
......@@ -311,8 +310,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private OnLayoutChangeListener mOnLayoutChangeListener;
private AlertDialog mAlertDialog;
private final DisplayMetrics mScreen = new DisplayMetrics();
protected boolean mIsBenchmark = false;
@Override
......@@ -735,7 +732,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (mPlaybackStarted || mService == null)
return;
mSavedRate = 1.0f;
mSavedTime = -1;
mPlaybackStarted = true;
......@@ -846,14 +842,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mSavedTime = getTime();
long length = mService.getLength();
//remove saved position if in the last 5 seconds
if (length - mSavedTime < 5000)
mSavedTime = 0;
else
mSavedTime -= 2000; // go back 2 seconds, to compensate loading time
if (length - mSavedTime < 5000) mSavedTime = 0;
else mSavedTime -= 2000; // go back 2 seconds, to compensate loading time
}
mSavedRate = mService.getRate();
mService.setRate(1.0f, false);
mService.stop();
}
......@@ -1094,20 +1086,16 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (mIsNavMenu)
return navigateDvdMenu(keyCode);
else if (!mShowing) {
if (mFov == 0f)
seekDelta(-10000);
else
mService.updateViewpoint(-5f, 0f, 0f, 0f, false);
if (mFov == 0f) seekDelta(-10000);
else mService.updateViewpoint(-5f, 0f, 0f, 0f, false);
return true;
}
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (mIsNavMenu)
return navigateDvdMenu(keyCode);
else if (!mShowing) {
if (mFov == 0f)
seekDelta(10000);
else
mService.updateViewpoint(5f, 0f, 0f, 0f, false);
if (mFov == 0f) seekDelta(10000);
else mService.updateViewpoint(5f, 0f, 0f, 0f, false);
return true;
}
case KeyEvent.KEYCODE_DPAD_UP:
......@@ -1117,10 +1105,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
volumeUp();
return true;
} else if (!mShowing) {
if (mFov == 0f)
showAdvancedOptions();
else
mService.updateViewpoint(0f, -5f, 0f, 0f, false);
if (mFov == 0f) showAdvancedOptions();
else mService.updateViewpoint(0f, -5f, 0f, 0f, false);
return true;
}
case KeyEvent.KEYCODE_DPAD_DOWN:
......@@ -1985,8 +1971,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
return mService != null && mTouchDelegate.onTouchEvent(event);
}
boolean updateViewpoint(float yaw, float pitch) {
return mService.updateViewpoint(yaw, pitch, 0, 0, false);
boolean updateViewpoint(float yaw, float pitch, float fov) {
return mService.updateViewpoint(yaw, pitch, 0, fov, false);
}
void initAudioVolume() {
......
......@@ -95,30 +95,29 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
player.sendMouseEvent(MotionEvent.ACTION_DOWN, xTouch, yTouch)
}
MotionEvent.ACTION_MOVE -> {
if (mTouchAction != TOUCH_IGNORE) {// Mouse events for the core
player.sendMouseEvent(MotionEvent.ACTION_MOVE, xTouch, yTouch)
if (player.fov == 0f) {
// No volume/brightness action if coef < 2 or a secondary display is connected
//TODO : Volume action when a secondary display is connected
if (mTouchAction != TOUCH_SEEK && coef > 2 && player.isOnPrimaryDisplay) {
if (Math.abs(yChanged / screenConfig.yRange) < 0.05)
return false
mTouchY = event.rawY
mTouchX = event.rawX
doVerticalTouchAction(yChanged)
} else {
// Seek (Right or Left move)
doSeekTouch(Math.round(deltaY), if (rtl) -xgesturesize else xgesturesize, false)
}
} else {
if (mTouchAction == TOUCH_IGNORE) return false
// Mouse events for the core
player.sendMouseEvent(MotionEvent.ACTION_MOVE, xTouch, yTouch)
if (player.fov == 0f) {
// No volume/brightness action if coef < 2 or a secondary display is connected
//TODO : Volume action when a secondary display is connected
if (mTouchAction != TOUCH_SEEK && coef > 2 && player.isOnPrimaryDisplay) {
if (Math.abs(yChanged / screenConfig.yRange) < 0.05) return false
mTouchY = event.rawY
mTouchX = event.rawX
mTouchAction = TOUCH_MOVE
val yaw = player.fov * -xChanged / screenConfig.xRange.toFloat()
val pitch = player.fov * -yChanged / screenConfig.xRange.toFloat()
player.updateViewpoint(yaw, pitch)
doVerticalTouchAction(yChanged)
} else {
// Seek (Right or Left move)
doSeekTouch(Math.round(deltaY), if (rtl) -xgesturesize else xgesturesize, false)
}
} else {
mTouchY = event.rawY
mTouchX = event.rawX
mTouchAction = TOUCH_MOVE
val yaw = player.fov * -xChanged / screenConfig.xRange.toFloat()
val pitch = player.fov * -yChanged / screenConfig.xRange.toFloat()
player.updateViewpoint(yaw, pitch, 0f)
}
}
MotionEvent.ACTION_UP -> {
......@@ -284,7 +283,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
override fun onScale(detector: ScaleGestureDetector): Boolean {
if (player.fov != 0f) {
val diff = VideoPlayerActivity.DEFAULT_FOV * (1 - detector.scaleFactor)
if (player.updateViewpoint(0f, 0f)) {
if (player.updateViewpoint(0f, 0f, diff)) {
player.fov = Math.min(Math.max(MIN_FOV, player.fov + diff), MAX_FOV)
return true
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment