-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong Direction for forwarding #15
Comments
XML <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.github.vkay94.dtpv.DoubleTapPlayerView
android:id="@+id/player"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
app:controller_layout_id="@layout/video_controls"
app:dtpv_controller="@id/youtube_overlay"
/>
<com.github.vkay94.dtpv.youtube.YouTubeOverlay
android:id="@+id/youtube_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
app:yt_backgroundCircleColor="#608E4EC7"
app:yt_seekSeconds="15"
app:yt_playerView="@id/player" />
<ProgressBar
android:id="@+id/load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> |
Hmm, I tried your XML and it works as expected. Could you give some more information? Like:
Regarding the Android version and manufacturer: it would be nice if you could check whether you encounter the problem in the sample app: Regarding the media type: I checked MP4 (and HLS in the past) and it works without problems, but I didn't try other formats. Do you mind share the loading code? Something like this, so I can check. Thanks |
I use Here is my loading code: private HlsMediaSource hlsFromURI(Uri uri) {
if (currentVideo != null) {
return (HlsMediaSource) currentVideo;
}
if (uri == null) {
return null;
}
DataSource.Factory factory = new DefaultDataSourceFactory(this, userAgent);
return new HlsMediaSource.Factory(factory).createMediaSource(MediaItem.fromUri(uri));
} I initialize DoubleTapView and YouTubeOverlay like this: protected void onCreate(@Nullable Bundle savedInstanceState) {
playerView = findViewById(R.id.player);
youTubeOverlay = findViewById(R.id.youtube_overlay);
youTubeOverlay.performListener(new YouTubeOverlay.PerformListener() {
@Override
public void onAnimationStart() {
youTubeOverlay.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd() {
youTubeOverlay.setVisibility(View.INVISIBLE);
}
@NotNull
@Override
public Boolean shouldForward(@NotNull Player player, @NotNull DoubleTapPlayerView doubleTapPlayerView, float v) {
return true;
}
});
//Some code
initPlayer();
}
private void initPlayer() {
exoPlayer = new SimpleExoPlayer.Builder(this).setTrackSelector(trackSelector).build();
exoPlayer.addListener(listener);
playerView.getSubtitleView().setStyle(STANDARD_CAPTION_STYLE);
youTubeOverlay.player(exoPlayer);
exoPlayer.addTextOutput(textOutput);
AudioAttributes audioAttributes = new AudioAttributes.Builder().setUsage(C.USAGE_MEDIA).setContentType(C.CONTENT_TYPE_MOVIE).build();
exoPlayer.setAudioAttributes(audioAttributes, true);
playerView.setPlayer(exoPlayer);
playerView.getSubtitleView().setApplyEmbeddedFontSizes(USE_SSA_STANDARD_PARSER);
playerView.getSubtitleView().setApplyEmbeddedStyles(USE_SSA_STANDARD_PARSER);
//A lot of code
} |
The reason lies in the The method is documented. I'll think about something to make it working in Java without self-overriding in the future. |
Yeah, overriting solved issue. Here is Java code: @Override
public Boolean shouldForward(@NotNull Player player, @NotNull DoubleTapPlayerView doubleTapPlayerView, float v) {
if (player.getPlaybackState() == PlaybackState.STATE_ERROR ||
player.getPlaybackState() == PlaybackState.STATE_NONE ||
player.getPlaybackState() == PlaybackState.STATE_STOPPED) {
playerView.cancelInDoubleTapMode();
return null;
}
if (player.getCurrentPosition() > 500 && v < playerView.getWidth() * 0.35)
return false;
if (player.getCurrentPosition() < player.getDuration() && v > playerView.getWidth() * 0.65)
return true;
return null;
} |
Great! |
When doubleclick on left side of the screen, it starts to forwarding in a positive diraction.
The text was updated successfully, but these errors were encountered: