Skip to content

Commit

Permalink
Tweak seek, update metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
moneytoo committed Feb 6, 2021
1 parent b3f51b5 commit b19ce0a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ HDR (HDR10+ and Dolby Vision) video playback on compatible/supported hardware.
* Playback speed control
* Horizontal swipe to quickly seek
* Vertical swipe to change brightness (left) / volume (right)
* Pinch to zoom (Android 7 or higher), since v0.19
* PiP (Picture in Picture) on Android 8 or higher
* Resize (fit/crop)
* Volume boost
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/com/brouken/player/CustomStyledPlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class CustomStyledPlayerView extends StyledPlayerView implements Ge

private boolean restorePlayState;

private ScaleGestureDetector mScaleDetector;
private final ScaleGestureDetector mScaleDetector;
private float mScaleFactor = 1.f;

public final Runnable textClearRunnable = () -> {
Expand Down Expand Up @@ -80,7 +80,7 @@ public void clearIcon() {

@Override
public boolean onTouchEvent(MotionEvent ev) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && gestureOrientation == Orientation.UNKNOWN)
mScaleDetector.onTouchEvent(ev);

switch (ev.getActionMasked()) {
Expand Down Expand Up @@ -184,23 +184,24 @@ public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float

gestureOrientation = Orientation.HORIZONTAL;
final long position;
float distanceDiff = Math.max(0.5f, Math.min(Math.abs(Utils.pxToDp(distanceX) / 4), 10.f));

if (PlayerActivity.haveMedia) {
if (gestureScrollX > 0) {
if (seekStart + seekChange - SEEK_STEP >= 0) {
if (seekStart + seekChange - SEEK_STEP * distanceDiff >= 0) {
PlayerActivity.player.setSeekParameters(SeekParameters.PREVIOUS_SYNC);
seekChange -= SEEK_STEP;
seekChange -= SEEK_STEP * distanceDiff;
position = seekStart + seekChange;
PlayerActivity.player.seekTo(position);
}
} else {
PlayerActivity.player.setSeekParameters(SeekParameters.NEXT_SYNC);
if (seekMax == C.TIME_UNSET) {
seekChange += SEEK_STEP;
seekChange += SEEK_STEP * distanceDiff;
position = seekStart + seekChange;
PlayerActivity.player.seekTo(position);
} else if (seekStart + seekChange + SEEK_STEP < seekMax) {
seekChange += SEEK_STEP;
seekChange += SEEK_STEP * distanceDiff;
position = seekStart + seekChange;
PlayerActivity.player.seekTo(position);
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/brouken/player/PlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public class PlayerActivity extends Activity {
private boolean play;
private float subtitlesScale = 1.0f;
private boolean scrubbing;
private long scrubbingStart;

final Rational rationalLimitWide = new Rational(239, 100);
final Rational rationalLimitTall = new Rational(100, 239);
Expand Down Expand Up @@ -164,6 +165,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onScrubStart(TimeBar timeBar, long position) {
scrubbing = false;
scrubbingStart = player.getCurrentPosition();
reportScrubbing(position);
}

Expand Down Expand Up @@ -961,13 +963,14 @@ void showSnack(final String textPrimary, final String textSecondary) {
}

void reportScrubbing(long position) {
final long diff = position - PlayerActivity.player.getCurrentPosition();
final long diff = position - scrubbingStart;
if (Math.abs(diff) > 1000) {
scrubbing = true;
}
if (scrubbing) {
playerView.clearIcon();
playerView.setCustomErrorMessage(Utils.formatMilis(diff));
}
player.seekTo(position);
}
}
6 changes: 3 additions & 3 deletions app/src/main/java/com/brouken/player/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public static int dpToPx(int dp) {
return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}

// public static int pxToDp(int px) {
// return (int) (px / Resources.getSystem().getDisplayMetrics().density);
// }
public static float pxToDp(float px) {
return px / Resources.getSystem().getDisplayMetrics().density;
}

public static boolean fileExists(final Context context, final Uri uri) {
if ("file".equals(uri.getScheme())) {
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/cs/full_description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Funkce
* Nastavení rychlosti přehrávání
* Horizontální swipe pro rychlý posun v čase
* Vertikální swipe pro změnu jasu (vlevo) / hlasitosti (vpravo)
* Zoom/přiblížení dvěma prsty (Android 7 a výš)
* Obraz v obraze (plovoucí okno) na Androidu 8 a výš
* Změna velikosti (přizpůsobení/oříznutí)
* Zvýšení hlasitosti
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/19.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add pinch to zoom (Android 7+) and other small fixes and improvements
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/full_description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Features
* Playback speed control
* Horizontal swipe to quickly seek
* Vertical swipe to change brightness (left) / volume (right)
* Pinch to zoom (Android 7 or higher)
* PiP (Picture in Picture) on Android 8 or higher
* Resize (fit/crop)
* Volume boost
Expand Down

0 comments on commit b19ce0a

Please sign in to comment.