Skip to content

Commit

Permalink
Add:Check for OnePlus on playing ab with local cover #35
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Jan 20, 2022
1 parent c07b527 commit 4cdcbf7
Showing 1 changed file with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -674,19 +674,29 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {

// Issue with onenote plus crashing when using local cover art. https://github.com/advplyr/audiobookshelf-app/issues/35
if (currentAudiobookStreamData?.coverUri != null && currentAudiobookStreamData?.isLocal == true) {
try {
Log.d(tag, "CHECKING COVER ${currentAudiobookStreamData?.coverUri}")
var file = DocumentFile.fromTreeUri(ctx, currentAudiobookStreamData!!.coverUri)
Log.d(tag, "GOT FILE ${file?.name} | ${file?.type} | Can Read: ${file?.canRead()} |isExternalStorageDocument: ${file?.isExternalStorageDocument}")
if (file?.canRead() !== true) {
Log.d(tag, "Invalid cover: no read access")
currentAudiobookStreamData?.clearCover()
}
} catch(e:Exception) {
Log.d(tag, "Invalid cover: Failed to read local cover file $e")
var deviceName = Build.DEVICE
var deviceMan = Build.MANUFACTURER
var deviceModel = Build.MODEL
Log.d(tag, "Checking device $deviceName | Model $deviceModel | Manufacturer $deviceMan")
if (deviceMan.toLowerCase().contains("oneplus") || deviceName.toLowerCase().contains("oneplus")) {
Log.d(tag, "Detected OnePlus device - removing local cover")
currentAudiobookStreamData?.clearCover()
e.printStackTrace()
}

// OnePlus devices were showing valid permissions for image
// try {
// Log.d(tag, "CHECKING COVER ${currentAudiobookStreamData?.coverUri}")
// var file = DocumentFile.fromTreeUri(ctx, currentAudiobookStreamData!!.coverUri)
// Log.d(tag, "GOT FILE ${file?.name} | ${file?.type} | Can Read: ${file?.canRead()} |isExternalStorageDocument: ${file?.isExternalStorageDocument}")
// if (file?.canRead() !== true) {
// Log.d(tag, "Invalid cover: no read access")
// currentAudiobookStreamData?.clearCover()
// }
// } catch(e:Exception) {
// Log.d(tag, "Invalid cover: Failed to read local cover file $e")
// currentAudiobookStreamData?.clearCover()
// e.printStackTrace()
// }
}

var metadata = currentAudiobookStreamData!!.getMediaMetadataCompat()
Expand Down

0 comments on commit 4cdcbf7

Please sign in to comment.