This is a migrated thread and some comments may be shown as answers.

Phonegap Media Background

20 Answers 197 Views
Apple iOS
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kirk Pinneo
Top achievements
Rank 1
Kirk Pinneo asked on 22 Jan 2013, 11:20 PM
I have an app that plays a media file but when it goes into the background on ios it stops. The solution is enable background playing via:

"Support for some types of background execution must be declared in advance by the app that uses them. An app declares support for a service using its Info.plist file. Add the UIBackgroundModes key to your Info.plist file and set its value to an array containing one or more of the following strings:audio—The app plays audible content to the user while in the background. (This content includes streaming audio or video content using AirPlay.)"

Is there a way to set this using Icenium?

20 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 23 Jan 2013, 07:58 AM
Hello Kirk,

Currently there is no official way for you to apply this configuration change. We are constantly expanding the iOS section of the project properties screen in Icenium and an addition for background modes sounds like a good option too. Can you please add this feature request to our feedback portal so other users can see it and vote for it?

Kind regards,
Stefan Dobrev
the Telerik team

Share feedback and vote for features on our Feedback Portal.
Want some Kendo UI online training - head over to Pluralsight.
0
Steve
Telerik team
answered on 05 Jul 2013, 03:01 PM
Hello Kirk,

We've added background modes for iOS in Icenium 1.5 and they can be set through the project properties.
What's more since v.1.6 we've given you full control by adding the ability to make configuration changes to your app by modifying the respective Info.plist and config.xml for iOS and AndroidManifest.xml and config.xml for Android directly in the Icenium code editor. For more information, see Edit Configuration Files.

Regards,
Steve
Telerik

Looking for tips & tricks directly from the Icenium team? Check out our blog!
Missed our first webinar, watch it here.
Share feedback and vote for features on our Feedback Portal.
0
Paul
Top achievements
Rank 1
answered on 24 Jan 2014, 11:39 PM
I am also trying to get my audio to keep playing when my app goes into the background or lock screen. I am building for iOS 7. I have set the plist file with Background Audio but I think, for iOS7 I also need:

            NSError *setCategoryError = nil;
            [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];

Within the cordova build. 

Do you know if and when you will be supporting this or If I can provide a the updated Obj C code to do this myself?
0
Steve
Telerik team
answered on 29 Jan 2014, 05:01 PM
Hi Paul,

According to the Apple documentation, setting UIBackgroundModes key with value audio, should allow apps to play audio in background. Here are several articles from Apple's documentation describing the process:

Regards,
Steve
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Paul
Top achievements
Rank 1
answered on 29 Jan 2014, 06:24 PM
Thanks for your reply. One more question. Have you come across any issues with ios7, Cordova media and shoutcast streams? I just cannot get it to work. I know from experience the obj c avaudio player does support shoutcast streaming. I'm just hoping you've happen upon a workaround which doesn't include using the html 5 audio tag. That does not play in the background. Audio fades out when I switch apps. I do have the background mode set to audio in the plist (in icenium)
0
Steve
Telerik team
answered on 31 Jan 2014, 01:32 PM
Hi Paul,

We're not aware neither have we come across such issues, but you should have in mind that you're not working directly with the native classes of iOS, rather you're using the Cordova shims, so there might be problems. You can quickly search the Cordova issue tracker for such, if it is not logged, it doesn't necessarily mean there is no problem.

If you isolate what you're trying to achieve in a simple demo we can look into, we could try to assist.

Regards,
Steve
Telerik
Icenium is now Telerik AppBuilder, and is part of the Telerik Platform. For more information on the new name, and to learn more about the Platform, register for the free online keynote and webinar on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT)
0
Paul
Top achievements
Rank 1
answered on 31 Jan 2014, 02:49 PM
Thanks again for your reply. I provided a simple demo using one of your demos. here is the link to download:

https://www.dropbox.com/s/576107dsujwn7bk/sample-media-player2.zip

What I am trying to achieve is the playback of the mp3 "stream". The url for the stream is in the provided demo code.

Deploying the app to an actual iOS 7 device causes the app to crash. 
0
Steve
Telerik team
answered on 05 Feb 2014, 12:03 PM
Hi Paul,

Unfortunately I could not test your project as http://s2.voscast.com:7762/ucy.mp3 does not open at all in our office. Can you check whether it still opens on your end? I also have suspicion that it might be our admins blocking that port as it is not a standard one, but I would have little luck convincing them to open it for me.

Still, I saw plenty of complaints that audio stream does not function in PhoneGap/Cordova. Take a look at the following articles:
  • http://www.joeldare.com/wiki/play_an_mp3_audio_stream_in_phonegap
  • https://github.com/devgeeks/ExampleHTML5AudioStreaming
Regards,
Steve
Telerik
Icenium is now Telerik AppBuilder, and is part of the Telerik Platform. For more information on the new name, and to learn more about the Platform, register for the free online keynote and webinar on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT)
0
Mark
Top achievements
Rank 1
answered on 18 Mar 2014, 04:49 AM
I am having the same issue playing an mp3 stream.  I copied the media app demo and the only change was the stream url.  When I click to play, it shows loading and then the app freezes.

I am able to play mp3 files that download.  It's when I send it a mp3 stream that it fails.  I tried the same stream using html5 audio and the stream plays, just not in background.  
0
Zdravko
Telerik team
answered on 20 Mar 2014, 03:52 PM
Hi Mark,

Our sample app is working fine when Background mode Audio is enabled. It still plays sound in the background.
Would you provide us the stream that fails so we can test with it?
Thanks.

Regards,
Zdravko
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.

 
0
Mark
Top achievements
Rank 1
answered on 20 Mar 2014, 05:49 PM
Here are two streams I tested with:

http://vprclassical.streamguys.net/vprclassical128.mp3

http://mp3.kvcr.org/livewintro.mp3

0
Kaloyan
Telerik team
answered on 25 Mar 2014, 02:42 PM
Hi Mark,

Thank you for the details.

Unfortunately, we found there is a known issue in Cordova that prevents playing audio streams on iOS devices. You can check it here and also here.

In order to check if the HTML 5 audio will play in background, you can enable the Audio Background Mode from the project properties (as my colleague has pointed), or add the audio and fetch background modes to your apps iOS Info.plist. Here are the exact lines:
<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
    <string>fetch</string>
</array>

I hope this helps.

Regards,
Kaloyan
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.

 
0
Mark
Top achievements
Rank 1
answered on 25 Mar 2014, 11:38 PM
HTML 5 does not play in the background.  I had already tested this, and tested one more time with the settings you suggested.
0
Mark
Top achievements
Rank 1
answered on 26 Mar 2014, 12:42 AM
Further research points to AVAudioSessionCategoryPlayback.  Is there a way to access AVAudioSession.h?

From apple - :  AVAudioSessionCategoryPlayback - For playing recorded music or other sounds that are central to the successful use of your app.  When using this category, your app audio continues with the Silent switch set to silent or when the screen locks. 

Another clue to this issue:  HTML 5 audio mp3 file not playing back when iphone locked

0
Kaloyan
Telerik team
answered on 28 Mar 2014, 01:52 PM
Hi again Mark,

Unfortunately, there is no way to access the AppDelegate.m file out of the box. The only possible approach at this stage is to develop a custom plugin, integrated inside your AppBuilder application that will do it for you.

However, as we understand this is not a trivial task at all, we decided to further investigate the issue and come up with a solution on our side that will allow streaming audio in the background. We will follow up on this here as soon as possible.

Until then, you can visit our Ideas and Feedback portal and add your feature requests there. I must say, I find the idea of being able to access the native files of your application rather good. Posting it there will also allow other Platform clients to vote for its implementation, which can speed up the whole process.

Thank you for the understanding. I hope this helps.

Regards,
Kaloyan
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.

 
0
Mark
Top achievements
Rank 1
answered on 14 Apr 2014, 04:42 PM
Look forward to you solution on streaming audio in the background.  Thanks!
0
Kaloyan
Telerik team
answered on 17 Apr 2014, 12:16 PM
Hi again Mark,

I will notify you as soon as we can provide the solution.

Thank you for your patience and understanding.

Regards,
Kaloyan
Telerik
 

Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

 
0
Rob
Top achievements
Rank 1
answered on 14 Jul 2014, 08:05 PM
Hello - There is a new plugin available on the Verified Plugins Marketplace that performs just what you were looking for:

http://plugins.telerik.com/plugin/backgroundaudio
0
Daniel
Top achievements
Rank 1
answered on 12 Sep 2014, 09:40 PM
Works great.  Thanks!
0
Sasa
Top achievements
Rank 1
answered on 21 Jan 2015, 06:13 PM
It does not work for me. I have also checked the background mode for Audio, and no luck...
Tags
Apple iOS
Asked by
Kirk Pinneo
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Steve
Telerik team
Paul
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Zdravko
Telerik team
Kaloyan
Telerik team
Rob
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Sasa
Top achievements
Rank 1
Share this question
or