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

When Application Launch, Music Player Stops in Ios #481

Open
jagan27101986 opened this issue Nov 13, 2019 · 10 comments
Open

When Application Launch, Music Player Stops in Ios #481

jagan27101986 opened this issue Nov 13, 2019 · 10 comments

Comments

@jagan27101986
Copy link

When the application starts in IOS after Splash Screen, the music player of IOS is stopped working.
We are using Ionic 4 application.
Please advise how to resolve the issue.

@andreveigaelias
Copy link

same problem

@kissk01
Copy link

kissk01 commented Nov 19, 2019

@jagan27101986
Copy link
Author

I resolved the issue by adding the following code
[session setCategory:AVAudioSessionCategoryAmbient
error:NULL];
in - (void) configureAudioSession method. Everthing works as expected.

@katzer - Could you please update in the file; so everytime i dont have have to copy and paste it.

@mehdis34
Copy link

I resolved the issue by adding the following code
[session setCategory:AVAudioSessionCategoryAmbient
error:NULL];
in - (void) configureAudioSession method. Everthing works as expected.

@katzer - Could you please update in the file; so everytime i dont have have to copy and paste it.

I have a same problem.
I tried your solution but it does not work for me.
Which file did you modify?

@jagan27101986
Copy link
Author

FileName - APPBackgroundMode.m
Copy and paste this method
/**

  • Configure the audio session.
    */
  • (void) configureAudioSession
    {
    AVAudioSession* session = [AVAudioSession
    sharedInstance];

    // Don't activate the audio session yet
    [session setActive:NO error:NULL];

    // Play music even in background and dont stop playing music
    // even another app starts playing sound
    [session setCategory:AVAudioSessionCategoryPlayback
    error:NULL];

    [session setCategory:AVAudioSessionCategoryAmbient
    error:NULL];

    // Active the audio session
    [session setActive:YES error:NULL];
    };

@paulovargatt
Copy link

FileName - APPBackgroundMode.m
Copie e cole este método
/ **

  • Configure a sessão de áudio.

    • /
  • (vazio) configureAudioSession
    {
    AVAudioSession * session = [AVAudioSession
    sharedInstance];
    // Não ative a sessão de áudio ainda
    [session setActive: NO error: NULL];
    // Toca música mesmo em segundo plano e não para de tocar
    // outro aplicativo começa a reproduzir som
    [session setCategory: AVAudioSessionCategoryPlayback
    error: NULL];
    [sessão setCategory:
    erro AVAudioSessionCategoryAmbient : NULL];
    // Ativa a sessão de áudio
    [session setActive: YES error: NULL];
    };

@jagan27101986 do you use cordova-music-controls? How do you control the media you're playing? ios overwrites the media controls automatically, i have been struggling for weeks...

@jagan27101986
Copy link
Author

The solution is only about when opening the application, the music player or any third party application stops playing the file. However, this has nothing to do with music controls.

@jagan27101986
Copy link
Author

@katzer - Could you please add the line [session setCategory:AVAudioSessionCategoryAmbient
error:NULL]; and update the git hub repo ?

@EinfachHans
Copy link

i think this Plugin is not maintained anymore, so i decided to create a new one and fix this Issue. It also has a Ionic Wrapper, so go ahead and use this: https://github.com/HansKrywaa/cordova-plugin-advanced-background-mode

@bassm
Copy link

bassm commented Aug 21, 2020

@HansKrywaa Thanks a lot your plugin saved me a lot of time. appreciate it man

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

7 participants