Skip to content
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

[Android] seeking causes the player to play on with no sound but SeekBar still running #1124

Closed
docaohuynh opened this issue Nov 20, 2023 · 16 comments
Assignees
Labels
1 backlog bug Something isn't working

Comments

@docaohuynh
Copy link

Which API doesn't behave as documented, and how does it misbehave?
When seek to specific time, seekbar still running with no sound

Minimal reproduction project
Provide a link here using one of two options:

  1. Using example in just_audio

To Reproduce (i.e. user steps, not code)
Steps to reproduce the behavior:

  1. Play audio
  2. Click seek
  3. Seekbar still process with no sound

Error messages

No

Expected behavior
Audio play immediately or show loading state when audio not playing until it actually play

Screenshots

7221666720455445413.mp4

Smartphone (please complete the following information):

  • Device: Samsung M21
  • OS: Android 12

Flutter SDK version

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.7, on macOS 13.4 22F66 darwin-x64, locale en-VN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.84.2)
[✓] Connected device (4 available)
[✓] Network resources
@docaohuynh docaohuynh added 1 backlog bug Something isn't working labels Nov 20, 2023
@ryanheise
Copy link
Owner

Using example in just_audio

I played your video but it doesn't sound like the example in just_audio. That is, you didn't actually provide me a way to reproduce this. It's likely related to the specific audio file you were playing.

@docaohuynh
Copy link
Author

@ryanheise
Copy link
Owner

Just checking but I assume you have read the trouble shooting section in the readme and this is something that is not already addressed there?

@docaohuynh
Copy link
Author

I have read "Audio file formats/encodings" but don't find the way to address with this issue. I play audio from url source so can not convert to MP3 format

@ryanheise
Copy link
Owner

I asked if you had read the entire troubleshooting section, in which there is more covered than just file formats/encodings.

@docaohuynh
Copy link
Author

I had read it again and still don't know where to address with this. I think it relate to this issue #1084

@ryanheise
Copy link
Owner

After you have read the troubleshooting, maybe you can share the relevant details regarding the file format and the server headers?

@docaohuynh
Copy link
Author

I use audio with info

Input #0, matroska,webm, from 'dictation.webm':
  Metadata:
    encoder         : google/video-file
  Duration: 00:01:00.36, start: -0.007000, bitrate: 117 kb/s
  Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)

I upload to dropbox server with response headers

Accept-Encoding:
identity,gzip
Accept-Ranges:
bytes
Cache-Control:
max-age=60
Content-Disposition:
inline; filename="dictation.webm"; filename*=UTF-8''dictation.webm
Content-Length:
888388
Content-Range:
bytes 0-888387/888388
Content-Security-Policy:
form-action 'none' ; report-uri https://www.dropbox.com/csp_log?policy_name=blockserver-noscript ; script-src 'unsafe-inline' https://www.google-analytics.com
Content-Security-Policy:
report-uri https://www.dropbox.com/csp_log?policy_name=blockserver-usercontent ; sandbox allow-forms allow-scripts allow-top-navigation allow-popups
Content-Type:
video/webm

@ryanheise
Copy link
Owner

Thank you. Since you are the one who uploaded the file to the server, can you explain why you couldn't upload it in a different format?

@docaohuynh
Copy link
Author

Because in my app user can play any audio from their device

@ryanheise
Copy link
Owner

I have just tested the example after changing the URL to the one provided, but could not reproduce the issue. After seeking, it shows the buffering spinner exactly up until the audio starts playing again. I don't know if that means it is a device specific behaviour, do you see this behaviour on other phones or just this one?

@docaohuynh
Copy link
Author

I tested on 3 devices and same error when seek to time seekbar running about 1-2s with no sound

  • Samsung Galaxy m21 (Android 12)
  • Galaxy Tab S6 lite (Android 13)
  • Oppo F1s (Android 6)

I can add this code to test seek function

Row(
    children: [
      IconButton(
        icon: const Icon(Icons.place_rounded),
        onPressed: () {
          _player.seek(const Duration(seconds: 30));
        },
      ),
      IconButton(
        icon: const Icon(Icons.place_rounded),
        onPressed: () {
          _player.seek(const Duration(seconds: 20));
        },
      ),
      IconButton(
        icon: const Icon(Icons.place_rounded),
        onPressed: () {
          _player.seek(const Duration(seconds: 10));
        },
      ),
      IconButton(
        icon: const Icon(Icons.place_rounded),
        onPressed: () {
          _player.seek(const Duration(seconds: 40));
        },
      ),
    ],
  )

@docaohuynh
Copy link
Author

I had try to add this code to seek function player.setSeekParameters(SeekParameters.CLOSEST_SYNC); it seem like fixed it fixed this issue but sometime it play wrong audio frame

AudioPlayer.java

int windowIndex = index != null ? index : player.getCurrentMediaItemIndex(); 
player.setSeekParameters(SeekParameters.CLOSEST_SYNC);
player.seekTo(windowIndex, position);

@ryanheise
Copy link
Owner

Regarding workarounds, you might also want to experiment with the buffering options. If all of your audio files are short like the one you linked to above, you could try to keep the whole file buffered in memory so that the buffering event that triggers this issue never happens.

@docaohuynh
Copy link
Author

Tks @ryanheise your your help. I will find some way to convert to another format it just happened in some url so I close this issue

Copy link

github-actions bot commented Dec 5, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants