Skip to content

Commit 9fb95e3

Browse files
committed
added: documentations to MediaItemTags.
1 parent 58a521c commit 9fb95e3

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

app/src/main/java/org/schabi/newpipe/player/Player.java

+1
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,7 @@ private void setMuteButton(@NonNull final ImageButton button, final boolean isMu
24862486
//////////////////////////////////////////////////////////////////////////*/
24872487
//region ExoPlayer listeners (that didn't fit in other categories)
24882488

2489+
@Override
24892490
public void onEvents(@NonNull final com.google.android.exoplayer2.Player player,
24902491
@NonNull final com.google.android.exoplayer2.Player.Events events) {
24912492
Listener.super.onEvents(player, events);

app/src/main/java/org/schabi/newpipe/player/mediaitem/ExceptionTag.java

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
import androidx.annotation.NonNull;
1111
import androidx.annotation.Nullable;
1212

13+
/**
14+
* This {@link MediaItemTag} object is designed to contain metadata for a stream
15+
* that has failed to load. It supplies metadata from an underlying
16+
* {@link PlayQueueItem}, which is used by the internal players to resolve actual
17+
* playback info.
18+
*
19+
* This {@link MediaItemTag} does not contain any {@link StreamInfo} that can be
20+
* used to start playback and can be detected by checking {@link ExceptionTag#getErrors()}
21+
* when in generic form.
22+
**/
1323
public final class ExceptionTag implements MediaItemTag {
1424
@NonNull
1525
private final PlayQueueItem item;

app/src/main/java/org/schabi/newpipe/player/mediaitem/MediaItemTag.java

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.google.android.exoplayer2.MediaItem;
66
import com.google.android.exoplayer2.MediaMetadata;
7+
import com.google.android.exoplayer2.Player;
78

89
import org.schabi.newpipe.extractor.stream.StreamInfo;
910
import org.schabi.newpipe.extractor.stream.StreamType;
@@ -16,6 +17,13 @@
1617
import androidx.annotation.NonNull;
1718
import androidx.annotation.Nullable;
1819

20+
/**
21+
* Metadata container and accessor used by player internals.
22+
*
23+
* This interface ensures consistency of fetching metadata on each stream,
24+
* which is encapsulated in a {@link MediaItem} and delivered via ExoPlayer's
25+
* {@link Player.Listener} on event triggers to the downstream users.
26+
**/
1927
public interface MediaItemTag {
2028

2129
List<Throwable> getErrors();

app/src/main/java/org/schabi/newpipe/player/mediaitem/PlaceholderTag.java

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
import androidx.annotation.NonNull;
1111
import androidx.annotation.Nullable;
1212

13+
/**
14+
* This is a Placeholding {@link MediaItemTag}, designed as a dummy metadata object for
15+
* any stream that has not been resolved.
16+
*
17+
* This object cannot be instantiated and does not hold real metadata of any form.
18+
* */
1319
public final class PlaceholderTag implements MediaItemTag {
1420
public static final PlaceholderTag EMPTY = new PlaceholderTag(null);
1521
private static final String UNKNOWN_VALUE_INTERNAL = "Placeholder";

app/src/main/java/org/schabi/newpipe/player/mediaitem/StreamInfoTag.java

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.schabi.newpipe.player.mediaitem;
22

3+
import com.google.android.exoplayer2.MediaItem;
4+
35
import org.schabi.newpipe.extractor.stream.StreamInfo;
46
import org.schabi.newpipe.extractor.stream.StreamType;
57
import org.schabi.newpipe.extractor.stream.VideoStream;
@@ -11,6 +13,12 @@
1113
import androidx.annotation.NonNull;
1214
import androidx.annotation.Nullable;
1315

16+
/**
17+
* This {@link MediaItemTag} object contains metadata for a resolved stream
18+
* that is ready for playback. This object guarantees the {@link StreamInfo}
19+
* is available and may provide the {@link Quality} of video stream used in
20+
* the {@link MediaItem}.
21+
**/
1422
public final class StreamInfoTag implements MediaItemTag {
1523
@NonNull
1624
private final StreamInfo streamInfo;

app/src/main/java/org/schabi/newpipe/player/mediasource/FailedMediaSource.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
import androidx.annotation.Nullable;
2424

2525
public class FailedMediaSource extends CompositeMediaSource<Void> implements ManagedMediaSource {
26-
private static final long SILENCE_DURATION_US = TimeUnit.SECONDS.toMicros(2);
26+
/**
27+
* Play 2 seconds of silenced audio when a stream fails to resolve due to a known issue,
28+
* such as {@link org.schabi.newpipe.extractor.exceptions.ExtractionException}.
29+
*
30+
* This silence duration allows user to react and have time to jump to a previous stream,
31+
* while still provide a smooth playback experience. A duration lower than 1 second is
32+
* not recommended, it may cause ExoPlayer to buffer for a while.
33+
* */
34+
public static final long SILENCE_DURATION_US = TimeUnit.SECONDS.toMicros(2);
2735

2836
private final String TAG = "FailedMediaSource@" + Integer.toHexString(hashCode());
2937
private final PlayQueueItem playQueueItem;
@@ -32,7 +40,7 @@ public class FailedMediaSource extends CompositeMediaSource<Void> implements Man
3240
private final MediaSource source;
3341
private final MediaItem mediaItem;
3442
/**
35-
* Permanently fail the play queue item associated with this source, with no hope of retrying.
43+
* Fail the play queue item associated with this source, with potential future retries.
3644
*
3745
* The error will be propagated if the cause for load exception is unspecified.
3846
* This means the error might be caused by reasons outside of extraction (e.g. no network).

0 commit comments

Comments
 (0)