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

Game stops music at opening - Android regression compare to cocos2d-x.3.14.1 #18465

Open
crazyhappygame opened this Issue Nov 13, 2017 · 12 comments

Comments

Projects
None yet
5 participants
@crazyhappygame
Contributor

crazyhappygame commented Nov 13, 2017

  • cocos2d-x version: 3.16
  • devices test on: Android/all
  • developing environments
    • NDK version: android-ndk-r14b
    • Xcode version:
    • VS version:
    • browser type and version:

Steps to Reproduce:

  1. Play music on Android device
  2. Run any cocos2d-x app

Bug:
cocos2d-x app stops music at opening:
This regression compare to cocos2d-x.3.14.1

@crazyhappygame

This comment has been minimized.

Show comment
Hide comment
@crazyhappygame

crazyhappygame Nov 13, 2017

Contributor

@dumganhar Is there any chance for some quick workaround?

Contributor

crazyhappygame commented Nov 13, 2017

@dumganhar Is there any chance for some quick workaround?

@dumganhar

This comment has been minimized.

Show comment
Hide comment
@dumganhar

dumganhar Nov 14, 2017

Perhaps you should modify code in Cocos2dxActivity.java

    @Override
    protected void onResume() {
    	Log.d(TAG, "onResume()");
        super.onResume();
        AudioManager manager =
            (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
       if (!manager.isMusicActive()) {
             Cocos2dxAudioFocusManager.registerAudioFocusListener(this);
       }
        this.hideVirtualButton();
       	resumeIfHasFocus();

dumganhar commented Nov 14, 2017

Perhaps you should modify code in Cocos2dxActivity.java

    @Override
    protected void onResume() {
    	Log.d(TAG, "onResume()");
        super.onResume();
        AudioManager manager =
            (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);
       if (!manager.isMusicActive()) {
             Cocos2dxAudioFocusManager.registerAudioFocusListener(this);
       }
        this.hideVirtualButton();
       	resumeIfHasFocus();
@AhmetAbak

This comment has been minimized.

Show comment
Hide comment
@AhmetAbak

AhmetAbak Nov 14, 2017

@dumganhar this solves the problem.

AhmetAbak commented Nov 14, 2017

@dumganhar this solves the problem.

@crazyhappygame

This comment has been minimized.

Show comment
Hide comment
@crazyhappygame

crazyhappygame Nov 14, 2017

Contributor

@dumganhar, AhmetAbak this change should be done in cocos2dx code or game code?

Contributor

crazyhappygame commented Nov 14, 2017

@dumganhar, AhmetAbak this change should be done in cocos2dx code or game code?

@crazyhappygame

This comment has been minimized.

Show comment
Hide comment
@crazyhappygame

crazyhappygame Nov 14, 2017

Contributor

@dumganhar could you also explain issue and how this change fix it? It is "proper fix" or some workaround?

Contributor

crazyhappygame commented Nov 14, 2017

@dumganhar could you also explain issue and how this change fix it? It is "proper fix" or some workaround?

@AhmetAbak

This comment has been minimized.

Show comment
Hide comment
@AhmetAbak

AhmetAbak Nov 14, 2017

@crazyhappygame i modified the Cocos2dxActivity class in cocos2dx library.

AhmetAbak commented Nov 14, 2017

@crazyhappygame i modified the Cocos2dxActivity class in cocos2dx library.

@dumganhar

This comment has been minimized.

Show comment
Hide comment
@dumganhar

dumganhar Nov 15, 2017

@AhmetAbak , good to know it works for you.

I think most games will take the ownership of audio, so it's a specific requirement.
Probably, we need to add a new interface for setting this.

dumganhar commented Nov 15, 2017

@AhmetAbak , good to know it works for you.

I think most games will take the ownership of audio, so it's a specific requirement.
Probably, we need to add a new interface for setting this.

@dumganhar

This comment has been minimized.

Show comment
Hide comment
@dumganhar

dumganhar Nov 15, 2017

could you also explain issue and how this change fix it? It is "proper fix" or some workaround?

It need to be tested. I think it's a fix not just a workaround.
But first of all, we need to define a new method for setting this.
Could you guys test this patch and give me the feedback? Thanks.

dumganhar commented Nov 15, 2017

could you also explain issue and how this change fix it? It is "proper fix" or some workaround?

It need to be tested. I think it's a fix not just a workaround.
But first of all, we need to define a new method for setting this.
Could you guys test this patch and give me the feedback? Thanks.

@AhmetAbak

This comment has been minimized.

Show comment
Hide comment
@AhmetAbak

AhmetAbak Nov 16, 2017

@dumganhar
crash log
I have a crash log related to Audio manager that surfaced with this version.
This may be one of the problems that should be solved with new AudioFocusManager.

AhmetAbak commented Nov 16, 2017

@dumganhar
crash log
I have a crash log related to Audio manager that surfaced with this version.
This may be one of the problems that should be solved with new AudioFocusManager.

@dumganhar

This comment has been minimized.

Show comment
Hide comment
@dumganhar

dumganhar Nov 21, 2017

@AhmetAbak Thanks for your feedback. I'm checking this issue now.

dumganhar commented Nov 21, 2017

@AhmetAbak Thanks for your feedback. I'm checking this issue now.

@crazyhappygame

This comment has been minimized.

Show comment
Hide comment
@crazyhappygame

crazyhappygame Dec 5, 2017

Contributor

@dumganhar did you have a chance to work on this issue? Is there chance to have fix in next release?

Contributor

crazyhappygame commented Dec 5, 2017

@dumganhar did you have a chance to work on this issue? Is there chance to have fix in next release?

@frozax

This comment has been minimized.

Show comment
Hide comment
@frozax

frozax Jan 17, 2018

I personally just commented the call Cocos2dxAudioFocusManager.registerAudioFocusListener(this) and both calls to Cocos2dxAudioFocusManager.unregisterAudioFocusListener(this) in Cocos2dxActivity.java.
I'll see if I have crash reports, the update is live.

frozax commented Jan 17, 2018

I personally just commented the call Cocos2dxAudioFocusManager.registerAudioFocusListener(this) and both calls to Cocos2dxAudioFocusManager.unregisterAudioFocusListener(this) in Cocos2dxActivity.java.
I'll see if I have crash reports, the update is live.

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