diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 2fb0d01..556baec 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -96,6 +96,7 @@ import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; +import com.google.android.exoplayer2.ui.DefaultTimeBar; import com.google.android.exoplayer2.ui.PlayerControlView; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; @@ -103,6 +104,7 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoListener; +import com.google.android.material.snackbar.Snackbar; import org.jetbrains.annotations.NotNull; @@ -975,6 +977,19 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd userHistory.setCurrentTime(previousPositionHistory); peertube.setUserHistory(userHistory); + + PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller); + DefaultTimeBar exo_progress = controlView.findViewById(R.id.exo_progress); + TextView exo_duration = controlView.findViewById(R.id.exo_duration); + if (peertube.isLive()) { + exo_progress.setVisibility(View.GONE); + exo_duration.setText(R.string.live); + exo_duration.setBackgroundResource(R.drawable.rounded_live); + } else { + exo_progress.setVisibility(View.VISIBLE); + exo_duration.setBackground(null); + } + if (peertube.getUserHistory() != null) { position = peertube.getUserHistory().getCurrentTime() * 1000; } @@ -1026,7 +1041,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd LinkedHashMap categoryInit = new LinkedHashMap<>(peertubeInformation.getCategories()); info_category.setText(categoryInit.get(peertube.getCategory().getId())); - info_duration.setText(Helper.secondsToString(peertube.getDuration())); + if (peertube.isLive()) { + info_duration.setText(R.string.live); + info_duration.setBackgroundResource(R.drawable.rounded_live); + } else { + info_duration.setText(Helper.secondsToString(peertube.getDuration())); + } + String format = DateFormat.getDateInstance(DateFormat.LONG).format(peertube.getPublishedAt()); info_published_at.setText(format); List tags = peertube.getTags(); @@ -1343,6 +1364,14 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd private void startStream(String videoURL, String streamingPlaylistsURLS, boolean autoPlay, long position, Uri subtitles, String lang, boolean promptNSFW) { + + if (peertube != null && peertube.isWaitTranscoding()) { + View parentLayout = findViewById(android.R.id.content); + Snackbar snackbar = Snackbar.make(parentLayout, R.string.live_not_started, Snackbar.LENGTH_INDEFINITE); + snackbar.setAction(R.string.close, view -> finish()); + snackbar.show(); + return; + } chromeCastVideoURL = videoURL; SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); String nsfwAction = sharedpreferences.getString(getString(R.string.set_video_sensitive_choice), Helper.BLUR); @@ -2064,6 +2093,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd openMainMenuOptions(); } }); + } private void setRequestedOrientationCustom(int orientationCustom) { diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java b/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java index 7bf47d4..1839872 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java @@ -88,6 +88,8 @@ public class VideoData { private List files; @SerializedName("id") private String id; + @SerializedName("isLive") + private boolean isLive = false; @SerializedName("isLocal") private boolean isLocal; @SerializedName("language") @@ -163,6 +165,7 @@ public class VideoData { this.files = new ArrayList<>(); in.readList(this.files, File.class.getClassLoader()); this.id = in.readString(); + this.isLive = in.readByte() != 0; this.isLocal = in.readByte() != 0; this.language = in.readParcelable(ItemStr.class.getClassLoader()); this.licence = in.readParcelable(Item.class.getClassLoader()); @@ -413,6 +416,14 @@ public class VideoData { this.id = id; } + public boolean isLive() { + return isLive; + } + + public void setLive(boolean live) { + isLive = live; + } + public boolean isLocal() { return isLocal; } @@ -668,6 +679,7 @@ public class VideoData { dest.writeString(this.embedUrl); dest.writeList(this.files); dest.writeString(this.id); + dest.writeByte(this.isLive ? (byte) 1 : (byte) 0); dest.writeByte(this.isLocal ? (byte) 1 : (byte) 0); dest.writeParcelable(this.language, flags); dest.writeParcelable(this.licence, flags); diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java index 5a4dd7e..9eb8135 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java @@ -147,7 +147,15 @@ public class PeertubeAdapter extends RecyclerView.Adapter + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 389c5ab..9dad1f4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -443,4 +443,6 @@ Language filter Filter videos with different languages + Live + This live has not started! \ No newline at end of file