Phonegap Media Background

21 posts, 0 answers
  1. Kirk Pinneo
    Kirk Pinneo avatar
    3 posts
    Member since:
    May 2006

    Posted 22 Jan 2013 Link to this post

    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?
  2. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 23 Jan 2013 Link to this post

    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.
  3. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 05 Jul 2013 Link to this post

    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.
  4. Paul
    Paul avatar
    3 posts
    Member since:
    Feb 2013

    Posted 24 Jan 2014 Link to this post

    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?
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 29 Jan 2014 Link to this post

    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.

  6. Paul
    Paul avatar
    3 posts
    Member since:
    Feb 2013

    Posted 29 Jan 2014 in reply to Steve Link to this post

    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)
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 31 Jan 2014 Link to this post

    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)
  8. Paul
    Paul avatar
    3 posts
    Member since:
    Feb 2013

    Posted 31 Jan 2014 in reply to Steve Link to this post

    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. 
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 05 Feb 2014 Link to this post

    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)
  10. Mark
    Mark avatar
    8 posts
    Member since:
    Sep 2012

    Posted 17 Mar 2014 in reply to Steve Link to this post

    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.  
  11. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 20 Mar 2014 Link to this post

    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.

     
  12. Mark
    Mark avatar
    8 posts
    Member since:
    Sep 2012

    Posted 20 Mar 2014 in reply to Zdravko Link to this post

    Here are two streams I tested with:

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

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

  13. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 25 Mar 2014 Link to this post

    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.

     
  14. Mark
    Mark avatar
    8 posts
    Member since:
    Sep 2012

    Posted 25 Mar 2014 in reply to Kaloyan Link to this post

    HTML 5 does not play in the background.  I had already tested this, and tested one more time with the settings you suggested.
  15. Mark
    Mark avatar
    8 posts
    Member since:
    Sep 2012

    Posted 25 Mar 2014 in reply to Mark Link to this post

    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

  16. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 28 Mar 2014 Link to this post

    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.

     
  17. Mark
    Mark avatar
    8 posts
    Member since:
    Sep 2012

    Posted 14 Apr 2014 in reply to Kaloyan Link to this post

    Look forward to you solution on streaming audio in the background.  Thanks!
  18. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 17 Apr 2014 Link to this post

    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!

     
  19. Rob
    Rob avatar
    11 posts
    Member since:
    Apr 2013

    Posted 14 Jul 2014 Link to this post

    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
  20. Daniel
    Daniel avatar
    1 posts
    Member since:
    Oct 2010

    Posted 12 Sep 2014 in reply to Rob Link to this post

    Works great.  Thanks!
  21. Sasa
    Sasa avatar
    1 posts
    Member since:
    Jan 2015

    Posted 21 Jan 2015 Link to this post

    It does not work for me. I have also checked the background mode for Audio, and no luck...
Back to Top