Skip to content

fix(android): Avoid playing after gaining focus in paused state#1857

Merged
Gustl22 merged 2 commits into
mainfrom
gustl22/1688-android-focus
Nov 18, 2024
Merged

fix(android): Avoid playing after gaining focus in paused state#1857
Gustl22 merged 2 commits into
mainfrom
gustl22/1688-android-focus

Conversation

@Gustl22

@Gustl22 Gustl22 commented Nov 17, 2024

Copy link
Copy Markdown
Collaborator

Description

Avoid playing when the app gains audio focus, e.g. after a phone call.
Also pause the audio when losing focus, or only pause it temporarly if losing transient focus.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, refactor:,
    docs:, chore:, test:, ci: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation and added dartdoc comments with ///, where necessary.
  • I have updated/added relevant examples in example.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Related Issues

closes #1853
closes #1854
closes #1688

@Gustl22 Gustl22 force-pushed the gustl22/1688-android-focus branch from f972094 to bfe14bd Compare November 17, 2024 22:32
@Gustl22

Gustl22 commented Nov 17, 2024

Copy link
Copy Markdown
Collaborator Author

@karthik986arre can you test, if this branch is fixing your issue?

@spydon spydon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, someone spoke about this on discord

@Gustl22 Gustl22 merged commit 01726c1 into main Nov 18, 2024
@Gustl22 Gustl22 deleted the gustl22/1688-android-focus branch November 18, 2024 19:56
@karthik986arre

Copy link
Copy Markdown

@Gustl22 it hasn't solve the problem, we have to reopen the related issues

@Gustl22

Gustl22 commented Dec 14, 2024

Copy link
Copy Markdown
Collaborator Author

@karthik986arre Thank you for testing.
Did you make sure to also override the
audioplayers_android dependency
as shown here: https://github.com/bluefireteam/audioplayers/blob/main/contributing.md#current-development

If you are sure, can you give me the exact steps to reproduce your issue, as I have followed the steps in the original one to solve it.

@karthik986arre

Copy link
Copy Markdown

Steps to reproduce:
Normal scenario:

  1. Play an audio from asset or over network
  2. Pause and resume the same audio

Interruption case:

  1. Play an audio from asset or over network
  2. Now Pause the player and interrupt via call
  3. Play the same audio

The issue is when intently pause and play the same audio! @Gustl22

@karthik986arre

Copy link
Copy Markdown

@Gustl22 any followup on this, please update if you got the issue!

@Gustl22

Gustl22 commented Jan 1, 2025

Copy link
Copy Markdown
Collaborator Author

@karthik986arre Did you make sure to also override the
audioplayers_android dependency
as shown here? https://github.com/bluefireteam/audioplayers/blob/main/contributing.md#current-development

@karthik986arre

Copy link
Copy Markdown
Screenrecorder-2025-01-02-12-18-53-979.mp4

I have done with override dependency in example project and causing same issues which mentioned above, please check this video FYI @Gustl22

@karthik986arre

Copy link
Copy Markdown

Hey @Gustl22, have you checked the above scenarios?

@Gustl22

Gustl22 commented Jan 7, 2025

Copy link
Copy Markdown
Collaborator Author

@karthik986arre I had no time to reproduce your scenario once again yet.
But during fixing I made sure to cover:

  • Playing Source
  • Pausing Source
  • Get an incoming phone call
  • The source won't continue to be played

I miss the step, where you receive the phone call in your video. (I tested it with the emulator, where one can also simulate phone calls). So I'm not sure, what your video tries to show, or what is wrong with it.

Edit: now I get it: the position stream is not updating after pause & play right(?)

@karthik986arre

Copy link
Copy Markdown

@Gustl22 yeah the position and duration stream are not updating when pause and playback the same audio.

@orestesgaolin

Copy link
Copy Markdown

Not sure if this is directly linked but I'm experiencing issues with audio focus during calls #1867

@arreshashikant

arreshashikant commented Jan 23, 2025

Copy link
Copy Markdown

This issue is fixed

Avoid playing when the app gains audio focus, e.g. after a phone call.

However, there's a new bug we see in this PR

Steps to reproduce:

  1. Start an audio X
  2. Pause the audio X
  3. Resume the audio X

After calling the resume API, Line no. 211 is executed, and then immediately line no. 220 is executed.
So, it is playing and then immediately pausing the audio
Screenshot 2025-01-23 at 7 04 08 PM

Tested on real android device
iQOO Z9s Pro 5g
Android 15

@Gustl22

Gustl22 commented Jan 26, 2025

Copy link
Copy Markdown
Collaborator Author

@karthik986arre can you have a look, if the issue is resolved in the current main branch?

@karthik986arre

Copy link
Copy Markdown

Thanks a lot @Gustl22, it's working fine now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto pause and play when interrupted by a call or other apps' media Paused playback resumes after incoming phone call

5 participants