Skip to content

Commit

Permalink
YTPlayerUtils: catch & report url validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gechoto authored Jan 5, 2025
1 parent d50c019 commit 599622d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/src/main/java/com/zionhuang/music/utils/YTPlayerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,15 @@ object YTPlayerUtils {
}

private fun validateStatus(url: String): Boolean {
val requestBuilder = okhttp3.Request.Builder()
.head()
.url(url)
val response = httpClient.newCall(requestBuilder.build()).execute()
return response.isSuccessful
try {
val requestBuilder = okhttp3.Request.Builder()
.head()
.url(url)
val response = httpClient.newCall(requestBuilder.build()).execute()
return response.isSuccessful
} catch (e: Exception) {
reportException(e)
}
return false
}
}

0 comments on commit 599622d

Please sign in to comment.