Cocos2d-x应用程序代码不允许音量控制按钮在iPhone或iPad上工作。

问题描述 投票:0回答:1

我无法确认这是否是自一个较新的iOS版本(也许11以后),但硬件音量按钮没有响应,而使用的应用程序,我目前正在更新。SimpleAudioEngine 虽然我看了一些其他使用Cocos2d-x的项目,但我还是尝试着使用了 SimpleAudioEngine 源,但没有成功。

cocos2d-x的版本是v2.1.1。

在我的 HelloWorldScene.cpp 我叫

`void HelloWorld::StartSoundAction()
{
    if(soundflag==0)
    {
        SimpleAudioEngine::sharedEngine()->playBackgroundMusic("background_music.mp3");
        soundflag=1;
    }
    else
    {
        SimpleAudioEngine::sharedEngine()->stopAllEffects();
        SimpleAudioEngine::sharedEngine()->playEffect("choose_your_patient3.mp3");
    }
}`

音乐工作,但我无法使用iPhone x或iPad Pro的硬件键控制音量。

ios cocos2d-x
1个回答
0
投票

在我的大多数应用程序中,我使用相同的语法,它是工作使用cocos2d-x版本3.17.2。

CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic();
CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("background4.mp3", true);

像这个

但只在老款iPhone SE硬件上测试。

© www.soinside.com 2019 - 2024. All rights reserved.