mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 00:30:03 +02:00
Some changes
This commit is contained in:
parent
c778c71306
commit
e18db746a0
7 changed files with 53 additions and 17 deletions
|
@ -139,9 +139,11 @@ dependencies {
|
|||
annotationProcessor "com.github.bumptech.glide:compiler:4.12.0"
|
||||
implementation 'jp.wasabeef:glide-transformations:4.3.0'
|
||||
implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.23.0'
|
||||
implementation 'androidx.media3:media3-exoplayer-hls:1.2.1'
|
||||
implementation "androidx.media3:media3-exoplayer:1.2.1"
|
||||
implementation "androidx.media3:media3-exoplayer-dash:1.2.1"
|
||||
implementation "androidx.media3:media3-ui:1.2.1"
|
||||
implementation "androidx.media3:media3-session:1.2.1"
|
||||
|
||||
|
||||
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.webkit.MimeTypeMap;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.exoplayer.ExoPlayer;
|
||||
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
@ -53,7 +54,7 @@ public class BasePeertubeActivity extends BaseBarActivity {
|
|||
|
||||
protected ActivityPeertubeBinding binding;
|
||||
protected VideoData.Video peertube;
|
||||
protected Player player;
|
||||
protected ExoPlayer player;
|
||||
protected String videoURL;
|
||||
protected String subtitlesStr;
|
||||
|
||||
|
|
|
@ -47,12 +47,12 @@ import android.content.res.Configuration;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
|
@ -77,6 +77,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||
|
@ -86,6 +87,7 @@ import androidx.core.app.ActivityCompat;
|
|||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
|
@ -96,19 +98,23 @@ import androidx.media3.common.VideoSize;
|
|||
import androidx.media3.datasource.DataSource;
|
||||
import androidx.media3.datasource.DefaultDataSource;
|
||||
import androidx.media3.exoplayer.ExoPlayer;
|
||||
import androidx.media3.exoplayer.hls.HlsMediaSource;
|
||||
import androidx.media3.exoplayer.source.MergingMediaSource;
|
||||
import androidx.media3.exoplayer.source.ProgressiveMediaSource;
|
||||
import androidx.media3.exoplayer.source.SingleSampleMediaSource;
|
||||
import androidx.media3.exoplayer.trackselection.AdaptiveTrackSelection;
|
||||
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector;
|
||||
import androidx.media3.exoplayer.trackselection.TrackSelector;
|
||||
import androidx.media3.session.MediaSession;
|
||||
import androidx.media3.ui.AspectRatioFrameLayout;
|
||||
import androidx.media3.ui.PlayerControlView;
|
||||
import androidx.media3.ui.DefaultTimeBar;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.vkay94.dtpv.DoubleTapPlayerView;
|
||||
import com.github.vkay94.dtpv.youtube.YouTubeOverlay;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
@ -203,7 +209,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
private Status status;
|
||||
private int flags;
|
||||
private boolean humanInteraction;
|
||||
|
||||
private MediaSession mediaSession;
|
||||
public static void hideKeyboard(Activity activity) {
|
||||
if (activity != null && activity.getWindow() != null) {
|
||||
activity.getWindow().getDecorView();
|
||||
|
@ -368,6 +374,26 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
binding.doubleTapPlayerView.setDoubleTapEnabled(true);
|
||||
binding.doubleTapPlayerView.setControllerShowTimeoutMs(0);
|
||||
binding.mediaVideo.performListener(new YouTubeOverlay.PerformListener() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Boolean shouldForward(@NonNull Player player, @NonNull DoubleTapPlayerView playerView, float posX) {
|
||||
if (player.getPlaybackState() == PlaybackState.STATE_ERROR ||
|
||||
player.getPlaybackState() == PlaybackState.STATE_NONE ||
|
||||
player.getPlaybackState() == Player.STATE_ENDED) {
|
||||
|
||||
playerView.cancelInDoubleTapMode();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (player.getCurrentPosition() > 500 && posX < playerView.getWidth() * 0.35)
|
||||
return false;
|
||||
|
||||
if (player.getCurrentPosition() < player.getDuration() && posX > playerView.getWidth() * 0.65)
|
||||
return true;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart() {
|
||||
binding.mediaVideo.setVisibility(View.VISIBLE);
|
||||
|
@ -1533,6 +1559,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
binding = null;
|
||||
if (player != null) {
|
||||
player.release();
|
||||
mediaSession = null;
|
||||
}
|
||||
unregisterReceiver();
|
||||
}
|
||||
|
@ -1612,13 +1639,10 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
if (playInMinimized && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && player != null) {
|
||||
isPlayInMinimized = true;
|
||||
setRequestedOrientationCustom(initialOrientation);
|
||||
MediaSessionCompat mediaSession = new MediaSessionCompat(this, getPackageName());
|
||||
MediaSessionConnector mediaSessionConnector = new MediaSessionConnector(mediaSession);
|
||||
mediaSessionConnector.setPlayer(player);
|
||||
mediaSession = new MediaSession.Builder(this, player).build();
|
||||
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||
controlView.hide();
|
||||
binding.doubleTapPlayerView.setControllerAutoShow(false);
|
||||
mediaSession.setActive(true);
|
||||
PictureInPictureParams params = new PictureInPictureParams.Builder().build();
|
||||
enterPictureInPictureMode(params);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
android:textColor="#FFBEBEBE"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.google.android.exoplayer2.ui.DefaultTimeBar
|
||||
<androidx.media3.ui.DefaultTimeBar
|
||||
android:id="@id/exo_progress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="26dp"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
android {
|
||||
compileSdk 34
|
||||
|
||||
|
@ -22,10 +23,18 @@ android {
|
|||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
namespace 'com.github.vkay94.dtpv'
|
||||
}
|
||||
|
||||
// Add a new configuration to hold your dependencies
|
||||
configurations {
|
||||
libConfig
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "androidx.appcompat:appcompat:1.6.1"
|
||||
|
|
|
@ -33,7 +33,7 @@ open class DoubleTapPlayerView @JvmOverloads constructor(
|
|||
private var controllerRef: Int = -1
|
||||
|
||||
init {
|
||||
gestureDetector = GestureDetectorCompat(context, gestureListener)
|
||||
gestureDetector = GestureDetectorCompat(context!!, gestureListener)
|
||||
|
||||
// Check whether controller is set through XML
|
||||
attrs?.let {
|
||||
|
|
|
@ -169,16 +169,16 @@ internal class CircleClipTapView(context: Context?, attrs: AttributeSet) :
|
|||
}
|
||||
|
||||
addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationStart(animation: Animator?) {
|
||||
override fun onAnimationStart(animation: Animator) {
|
||||
visibility = VISIBLE
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
if (!forceReset) performAtEnd()
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animator?) {}
|
||||
override fun onAnimationCancel(animation: Animator?) {}
|
||||
override fun onAnimationRepeat(animation: Animator) {}
|
||||
override fun onAnimationCancel(animation: Animator) {}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -208,14 +208,14 @@ internal class CircleClipTapView(context: Context?, attrs: AttributeSet) :
|
|||
updatePathShape()
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
|
||||
// Background
|
||||
canvas?.clipPath(shapePath)
|
||||
canvas?.drawPath(shapePath, backgroundPaint)
|
||||
canvas.clipPath(shapePath)
|
||||
canvas.drawPath(shapePath, backgroundPaint)
|
||||
|
||||
// Circle
|
||||
canvas?.drawCircle(cX, cY, currentRadius, circlePaint)
|
||||
canvas.drawCircle(cX, cY, currentRadius, circlePaint)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue