catch exceptions thrown at getArtist
This commit is contained in:
parent
51317acb86
commit
e74a60038a
2 changed files with 9 additions and 5 deletions
|
@ -60,12 +60,12 @@ class PropertiesDialog() {
|
|||
addProperty(R.string.resolution, file.getResolution().formatAsResolution())
|
||||
} else if (file.isAudioSlow()) {
|
||||
file.getDuration()?.let { addProperty(R.string.duration, it) }
|
||||
addProperty(R.string.artist, file.getArtist())
|
||||
file.getArtist()?.let { addProperty(R.string.artist, it) }
|
||||
addProperty(R.string.album, file.getAlbum())
|
||||
} else if (file.isVideoSlow()) {
|
||||
file.getDuration()?.let { addProperty(R.string.duration, it) }
|
||||
addProperty(R.string.resolution, file.getResolution().formatAsResolution())
|
||||
addProperty(R.string.artist, file.getArtist())
|
||||
file.getArtist()?.let { addProperty(R.string.artist, it) }
|
||||
addProperty(R.string.album, file.getAlbum())
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,13 @@ fun File.getDuration(): String? {
|
|||
}
|
||||
|
||||
fun File.getArtist(): String? {
|
||||
val retriever = MediaMetadataRetriever()
|
||||
retriever.setDataSource(absolutePath)
|
||||
return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST)
|
||||
try {
|
||||
val retriever = MediaMetadataRetriever()
|
||||
retriever.setDataSource(absolutePath)
|
||||
return retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST)
|
||||
} catch (ignored: Exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun File.getAlbum(): String? {
|
||||
|
|
Loading…
Reference in a new issue