-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
135 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
new-player/src/main/java/net/newpipe/newplayer/utils/NewPlayerLoadErrorHandlingPolicy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.newpipe.newplayer.utils | ||
|
||
import androidx.media3.common.util.UnstableApi | ||
import androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy | ||
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy | ||
import net.newpipe.newplayer.NewPlayer | ||
|
||
@UnstableApi | ||
class NewPlayerLoadErrorHandlingPolicy(val exceptionHandler: (Exception) -> Unit) : | ||
DefaultLoadErrorHandlingPolicy() { | ||
override fun getFallbackSelectionFor( | ||
fallbackOptions: LoadErrorHandlingPolicy.FallbackOptions, | ||
loadErrorInfo: LoadErrorHandlingPolicy.LoadErrorInfo | ||
): LoadErrorHandlingPolicy.FallbackSelection? { | ||
val fallbackSelection = super.getFallbackSelectionFor(fallbackOptions, loadErrorInfo) | ||
exceptionHandler(loadErrorInfo.exception) | ||
return fallbackSelection | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test-app/src/main/java/net/newpipe/newplayer/testapp/streamErrorHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.newpipe.newplayer.testapp | ||
|
||
import androidx.media3.common.MediaItem | ||
import net.newpipe.newplayer.MediaRepository | ||
import net.newpipe.newplayer.utils.NoResponse | ||
import net.newpipe.newplayer.utils.SingleSelection | ||
import net.newpipe.newplayer.utils.StreamExceptionResponse | ||
import net.newpipe.newplayer.utils.StreamSelectionResponse | ||
import java.lang.Exception | ||
|
||
suspend fun streamErrorHandler( | ||
item: String?, | ||
mediaItem: MediaItem?, | ||
exception: Exception, | ||
repository: MediaRepository | ||
): StreamExceptionResponse { | ||
return if (item == "faulty") { | ||
StreamSelectionResponse(SingleSelection(item, repository.getStreams("6502")[0])) | ||
} else { | ||
NoResponse() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters