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

Audio not playing sometimes #327

Open
3 tasks done
CodeWithOz opened this issue Jan 14, 2022 · 0 comments
Open
3 tasks done

Audio not playing sometimes #327

CodeWithOz opened this issue Jan 14, 2022 · 0 comments

Comments

@CodeWithOz
Copy link

Bug Report

Problem

Sound doesn't play even when there's no error

What is expected to happen?

The sound comes out from the device as expected when I play the audio object.

What does actually happen?

I have 2 test devices, and on one of them the sound plays but on the other it was playing earlier today but has stopped playing now. The sound doesn't play even though the volume is set to 1.0 and the status callback shows the status as going from 1 to 2 then to 4.

Information

This may sound similar to this issue but I'm not getting the abort error that's reported there.

Command or Code

This is the code I use to play media:

export function playNewMsgAudio(isSend = false) {
    const audioObj = new Media(
        `${cordova.file.applicationDirectory}www/audio/${
            isSend ? 'send' : 'recv'
        }-msg.mp3`,
        () => {},
        error =>
            logError(
                'failed to initialize audio object for sent message',
                { error }
            ),
        status => {
            switch (status) {
                case Media.MEDIA_PAUSED:
                case Media.MEDIA_STOPPED:
                    audioObj.release();
                    break;
                default:
                    break;
            }
        }
    );
    audioObj.play();
    audioObj.setVolume('1.0');
}

Environment, Platform, Device

Samsung Note 20 Ultra running Android 11, Tekno Pop2 Plus running Android 8.

Version information

Cordova Android 10.1.1, cordova cli 10

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
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

No branches or pull requests

1 participant