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:
parent
192b917904
commit
bb704ea3fd
1 changed files with 5 additions and 4 deletions
|
@ -57,12 +57,13 @@ data class AudioInfo(
|
||||||
*/
|
*/
|
||||||
class AudioInfoProviderImpl @Inject constructor(@ApplicationContext private val context: Context) :
|
class AudioInfoProviderImpl @Inject constructor(@ApplicationContext private val context: Context) :
|
||||||
AudioInfo.Provider {
|
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 {
|
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 {
|
try {
|
||||||
extractor.setDataSource(context, song.uri, emptyMap())
|
extractor.setDataSource(context, song.uri, emptyMap())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
Loading…
Reference in a new issue