1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-01-08 16:30:34 +00:00

media browser: kotlin fixes

This commit is contained in:
Haggai Eran 2024-09-05 21:08:12 +03:00 committed by Siddhesh Naik
parent bf59f1e09d
commit 9f26137b9c
2 changed files with 8 additions and 5 deletions

View File

@ -58,7 +58,7 @@ class PlayerService : MediaBrowserServiceCompat() {
private var mediaBrowserConnector: MediaBrowserConnector? = null private var mediaBrowserConnector: MediaBrowserConnector? = null
get() { get() {
if (field == null) { if (field == null) {
return MediaBrowserConnector(this) field = MediaBrowserConnector(this)
} }
return field return field
} }

View File

@ -263,7 +263,7 @@ class MediaBrowserConnector(private val playerService: PlayerService) : Playback
try { try {
val parentIdUri = Uri.parse(parentId) val parentIdUri = Uri.parse(parentId)
val path = parentIdUri.pathSegments val path = ArrayList(parentIdUri.pathSegments)
if (path.isEmpty()) { if (path.isEmpty()) {
val mediaItems: MutableList<MediaBrowserCompat.MediaItem> = ArrayList() val mediaItems: MutableList<MediaBrowserCompat.MediaItem> = ArrayList()
@ -431,7 +431,7 @@ class MediaBrowserConnector(private val playerService: PlayerService) : Playback
private fun extractPlayQueueFromMediaId(mediaId: String): Single<PlayQueue> { private fun extractPlayQueueFromMediaId(mediaId: String): Single<PlayQueue> {
try { try {
val mediaIdUri = Uri.parse(mediaId) val mediaIdUri = Uri.parse(mediaId)
val path = mediaIdUri.pathSegments val path = ArrayList(mediaIdUri.pathSegments)
if (path.isEmpty()) { if (path.isEmpty()) {
throw parseError() throw parseError()
@ -461,14 +461,17 @@ class MediaBrowserConnector(private val playerService: PlayerService) : Playback
@Throws(ContentNotAvailableException::class) @Throws(ContentNotAvailableException::class)
private fun extractPlayQueueFromPlaylistMediaId( private fun extractPlayQueueFromPlaylistMediaId(
mediaIdSegments: List<String>, mediaIdSegments: ArrayList<String>,
url: String?, url: String?,
): Single<PlayQueue> { ): Single<PlayQueue> {
if (mediaIdSegments.isEmpty()) { if (mediaIdSegments.isEmpty()) {
throw parseError() throw parseError()
} }
when (val playlistType = mediaIdSegments.first()) { val playlistType = mediaIdSegments.first()
mediaIdSegments.removeAt(0)
when (playlistType) {
ID_LOCAL, ID_REMOTE -> { ID_LOCAL, ID_REMOTE -> {
if (mediaIdSegments.size != 2) { if (mediaIdSegments.size != 2) {
throw parseError() throw parseError()