-
-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] Player unresponsive after playback-error caused by certain MP3's with APIC metadata. #509
Comments
@dcvz or @Guichaguri, Any thoughts on this? |
@dcvz, I have found a potential solution to It seems that SwiftAudio is not creating a new AVPlayer instance after a status of For more detail see the issue I have created on the SwiftAudio repo. I implemented a quick version of the fix described by Apple here: curiousdustin/SwiftAudio@8b91573 |
@dcvz, regarding For some reason loading tracks with this problematic image metadata in an async manner such as in this PR, jorgenhenrichsen/SwiftAudio#51, avoids the issue. The track still takes much longer to load than a normal track, but at least it does not completely fail. However, I have concerns about how this change would affect the ability to use TrackPlayer commands in order even with promises, because the promise from |
@curiousdustin Hi, Do you have any luck on this. Can you please share the same with us. I am also facing the same issue. Have you fixed/completed the same in any of the branches. Thank you in advance. |
First of all the best is to fix your media files if possible. For our project we just stripped out the image meta data. Next fixing the unresponsiveness involves modifying the 3rd party library SwiftAudio. The solution I am currently using is my own attempt on my own fork/branch: curiousdustin/SwiftAudio@6a06eba However, the author of SwiftAudio has since merged a PR that is his own (more complete) solution: jorgenhenrichsen/SwiftAudio#60 The current version of react-native-track-player does not include this update. However, I believe the next release will, as I noticed @dcvz has recently switched from including a copy of Swift Audio to referencing a forked version that will be maintained for RNTP. #615 |
The fix for this is now included in SwiftAudio. |
Apologies for the essay, but this is a complicated issue and I want to provide as much info as possible.
The Symptoms
In my app, I was experiencing strange behavior after certain tracks would fail to load. After one of these tracks failed to load, no future tracks would load either, even when they had loaded and played just fine previously.
I was able to track down the problem tracks and realized that they all had APIC metadata (album art embedded in the mp3).
After stripping out this artwork, the track load fine and do not cause the issue.
Many tracks DO load just fine even when they have this image metadata. So, perhaps in some cases it is corrupt or something. Either way, they load fine after removing the image metadata.
Reference
For reference, here are the files I am using to test with, and without, this image metadata:
https://livestage.curiousmedia.com/public/pin/audio/problem-track-with-image-metadata.mp3
https://livestage.curiousmedia.com/public/pin/audio/problem-track-without-image-metadata.mp3
Here is a comparison with a branch where I have modified the basic example to show the behavior, log a bit more info, and also attempt a solution. The solution is not complete, more on that later.
Testing
The app behaves as expected and plays the demo tracks that are in the example without issue. However, when I skip to the
with-image
track, it loads for longer than usual, and then gives aplayback-error
.After this occurs, skipping to either next or previous tracks continues to result in the same
playback-error
. This continues until the app is closed and reopened.Attempted Solution
The
AVWrapper
error is not all that helpful, but it lead me to this thread, which suggested usingloadValuesAsynchronouslyForKeys
, before creating theAVPlayerItem
.You can see my attempt at doing that in the
loadAsync
method in the branch comparison.This actually DOES work to some degree. The track finally does load after longer than expected, and the
playback-error
is avoided. However, this is asynchronous, so it breaks certain things because the promise that caused the load to happen is resolved before the track is actually loaded, and before thecurrentItem
is set/updated.So for instance, with this solution, you would not be able to do something like:
play()
resolves before the player is actually ready to seek.So, this is by no means a final solution, but it DID help the issue.
I think there are really 2 issues that need to be solved here:
Can this library handle this sort of metadata in a better way that does not result in a failure to play?
What needs to be done in order to gracefully recover from this error, if it cannot be avoided?
The text was updated successfully, but these errors were encountered: