iOS Question How to add key add UIBackgroundModes to play music background

tuhatinhvn

Active Member
Licensed User
Longtime User
I read about how to make an app to run in background
My app is play music, i use video view to play it (hide control)
But when user press home or screen is off , my app is pause

I read in apple and stack overflow about it, they say about UIBackgroundModes
I know it but can not know how to make it with b4I.
Any one can help me?
Thank you!
Once the project has been created go to File-Info.plist and addUIBackgroundModes as a new row. It should then create the array.

Open the array and to the right of Item 0 set it to audio. Your File-Info.plistshould look like this:

01.jpg


Now go to the target settings and go to the tab labeled Build Phases.
 
Last edited:

tuhatinhvn

Active Member
Licensed User
Longtime User
Thank you for your reply, it is very goood, but with my project, i checked
UIBackgroundModes in project file is ok, use PlistExtra is ok

But with Video View (which object i use to play music online) when i press home or turn off screen , app is mute music

I upload my project here, can you see it for me, how to play when screen is off?
 

Attachments

  • to-erel.zip
    375.2 KB · Views: 368
Upvote 0

tuhatinhvn

Active Member
Licensed User
Longtime User
I tried with media player and
B4X:
#PlistExtra: <key>UIBackgroundModes</key><array><string>audio</string></array>
It play music ok
But when press home or screen turn off , music is pause

I think need some thing? Any one try it?
My project is below
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
   
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #PlistExtra: <key>UIBackgroundModes</key><array><string>audio</string></array>

#End Region

........etc

b.Initialize(File.DirAssets,"1.mp3","b")
b.Play

.....etc
 
Upvote 0
Top