music: fix broken audio info extraction

Fix an issue where audio info extraction would break if done
consequtively.

Accidentally released a global state instance of the extractor. Now
that it's a local instance, the issue should not occur.
This commit is contained in:
Alexander Capehart 2023-02-19 13:11:54 -07:00
parent 192b917904
commit bb704ea3fd
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -57,12 +57,13 @@ data class AudioInfo(
*/
class AudioInfoProviderImpl @Inject constructor(@ApplicationContext private val context: Context) :
AudioInfo.Provider {
// While we would use ExoPlayer to extract this information, it doesn't support
// common data like bit rate in progressive data sources due to there being no
// demand. Thus, we are stuck with the inferior OS-provided MediaExtractor.
private val extractor = MediaExtractor()
override suspend fun extract(song: Song): AudioInfo {
// While we would use ExoPlayer to extract this information, it doesn't support
// common data like bit rate in progressive data sources due to there being no
// demand. Thus, we are stuck with the inferior OS-provided MediaExtractor.
val extractor = MediaExtractor()
try {
extractor.setDataSource(context, song.uri, emptyMap())
} catch (e: Exception) {