Skip to content

Commit

Permalink
working on 5.0.0 I guess and added toasts for errors in player
Browse files Browse the repository at this point in the history
  • Loading branch information
Blatzar committed Jan 25, 2021
1 parent 2a24f5e commit c54a3c5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {

defaultConfig {
applicationId "com.lagradost.fastani"
minSdkVersion 23
minSdkVersion 21
targetSdkVersion 28
versionCode 10
versionName "2.1.0"
Expand Down
29 changes: 28 additions & 1 deletion app/src/main/java/com/lagradost/fastani/ui/PlayerFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import android.os.SystemClock
import android.preference.PreferenceManager
import android.view.*
import android.view.View.*
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import androidx.appcompat.app.AlertDialog
import com.fasterxml.jackson.annotation.JsonProperty
import com.google.android.exoplayer2.*
Expand Down Expand Up @@ -634,7 +636,6 @@ class PlayerFragment(private var data: PlayerData) : Fragment() {
super.onSaveInstanceState(outState)
}


private fun initPlayer() {
// NEEDED FOR HEADERS
var currentUrl = getCurrentUrl()
Expand Down Expand Up @@ -742,6 +743,32 @@ class PlayerFragment(private var data: PlayerData) : Fragment() {
MainActivity.requestAudioFocus()
}
}

override fun onPlayerError(error: ExoPlaybackException) {
// Lets pray this doesn't spam Toasts :)
when (error.type) {
ExoPlaybackException.TYPE_SOURCE -> {
Toast.makeText(activity, "Source error\n" + error.sourceException.message, LENGTH_LONG).show()
}
ExoPlaybackException.TYPE_RENDERER -> {
Toast.makeText(activity, "Renderer error\n" + error.rendererException.message, LENGTH_LONG).show()
}
ExoPlaybackException.TYPE_UNEXPECTED -> {
Toast.makeText(
activity,
"Unexpected player error\n" + error.unexpectedException.message,
LENGTH_LONG
).show()
}
ExoPlaybackException.TYPE_TIMEOUT -> {
Toast.makeText(
activity,
"Timeout error\n" + error.unexpectedException.message,
LENGTH_LONG
).show()
}
}
}
})
}

Expand Down

0 comments on commit c54a3c5

Please sign in to comment.