Skip to content

Commit 1eedfd7

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Convert /newpipe/util/StreamTypeUtil to kotlin
1 parent 2c7654a commit 1eedfd7

2 files changed

Lines changed: 54 additions & 50 deletions

File tree

app/src/main/java/org/schabi/newpipe/util/StreamTypeUtil.java

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2021-2026 NewPipe contributors <https://newpipe.net>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.util
7+
8+
import org.schabi.newpipe.extractor.stream.StreamType
9+
10+
/**
11+
* Utility class for [StreamType].
12+
*/
13+
object StreamTypeUtil {
14+
/**
15+
* Check if the [StreamType] of a stream is a livestream.
16+
*
17+
* @param streamType the stream type of the stream
18+
* @return whether the stream type is [StreamType.AUDIO_STREAM],
19+
* [StreamType.AUDIO_LIVE_STREAM] or [StreamType.POST_LIVE_AUDIO_STREAM]
20+
*/
21+
@JvmStatic
22+
fun isAudio(streamType: StreamType): Boolean {
23+
return streamType == StreamType.AUDIO_STREAM ||
24+
streamType == StreamType.AUDIO_LIVE_STREAM ||
25+
streamType == StreamType.POST_LIVE_AUDIO_STREAM
26+
}
27+
28+
/**
29+
* Check if the [StreamType] of a stream is a livestream.
30+
*
31+
* @param streamType the stream type of the stream
32+
* @return whether the stream type is [StreamType.VIDEO_STREAM],
33+
* [StreamType.LIVE_STREAM] or [StreamType.POST_LIVE_STREAM]
34+
*/
35+
@JvmStatic
36+
fun isVideo(streamType: StreamType): Boolean {
37+
return streamType == StreamType.VIDEO_STREAM ||
38+
streamType == StreamType.LIVE_STREAM ||
39+
streamType == StreamType.POST_LIVE_STREAM
40+
}
41+
42+
/**
43+
* Check if the [StreamType] of a stream is a livestream.
44+
*
45+
* @param streamType the stream type of the stream
46+
* @return whether the stream type is [StreamType.LIVE_STREAM] or
47+
* [StreamType.AUDIO_LIVE_STREAM]
48+
*/
49+
@JvmStatic
50+
fun isLiveStream(streamType: StreamType): Boolean {
51+
return streamType == StreamType.LIVE_STREAM ||
52+
streamType == StreamType.AUDIO_LIVE_STREAM
53+
}
54+
}

0 commit comments

Comments
 (0)