Can play music when the phone screen is turned off?

Is there a way to play background music or sound effects when the phone screen is turned off?
Please help me!

This is more of an OS thing than a cocos thing, for example, on Apple devices:

https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos/enabling_background_audio

1 Like

Thank you. But I want to ask how to write code so that the application still plays music when the screen is off.

You don’t need any code per se. You need to enable background mode for the app in iOS and/or Android permissions layers outside of code, and then make sure your app does not stop music when you go outside the app.

1 Like

How to stop the application, the background music still runs. Can you help me?

Who can help me?