apache / apache/cordova-plugin-media

AudioPlayerError: pausePlaying() called duringinvalid state: 2

Open
#399 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
391
Forks
762
PR merge metrics
No merged PRs in 30d

Description

# Bug Report

## Problem
While recording, the phone rang, prompting an AudioPlayerError: pausePlaying() called during invalid state: 2, but the recording was not affected, which is normal. I reviewed the code and believe that the pauseAllLostFocus method should not handle the audio class during recording.

### What is expected to happen?

### What does actually happen?

## Information

### Command or Code

``
public void pauseAllLostFocus() {
for (AudioPlayer audio : this.players.values()) {
if (audio.getState() == AudioPlayer.STATE.MEDIA_RUNNING.ordinal()) {
this.pausedForFocus.add(audio);
audio.pausePlaying();
}
}
}
``

### Environment, Platform, Device

### Version information

## Checklist

- [ ] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [ ] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start at pauseAllLostFocus() and inspect how AudioPlayer states are represented and how recording interacts with focus loss. Reproduce the phone-call interruption if possible, then verify that recording does not trigger pausePlaying() while the invalid-state error is avoided.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.