3 Replies Latest reply on Jan 2, 2017 3:01 AM by VectorP

    Locked screen audio controls

    georgej19520886

      Hello

       

      I have been searching for a long time for a solution to this problem but I just can't find one.

       

      I have built an app that plays audio using html5. All I want is for a user to be able to play/pause and skip forward/backwards from a locked screen but I can't get those buttons to display. I am testing on an iPhone. Among a few other things, I have tried this solution GitHub - shi11/RemoteControls: cordova 3 plugin for interacting with ios7 remote controls and metadata

      as well as this GitHub - homerours/cordova-music-controls-plugin: A Cordova plugin displaying music controls in notifications (cordova-p…

      but I can't get either one to work. I'm not sure what I may be doing wrong.

       

      I'm using phonegap build and my config.xml file has the following plugins.

       

      <plugin spec="https://github.com/AubreyHewes/cordova-background-audio.git"/> 

      <plugin name="cordova-plugin-streaming-media"/>

      <plugin spec="https://github.com/shi11/RemoteControls.git"/>

      <plugin name="com.rd11.remote-controls" />

      <plugin name="cordova-plugin-music-controls" />

       

      Any direction would be very much appreciated.

       

      George

        • 1. Re: Locked screen audio controls
          VectorP Level 4

          <plugin spec="https://github.com/AubreyHewes/cordova-background-audio.git"/> 

          The README for this plugin says: "Phonegap Build: deprecated. no longer seems to work"

           

          <plugin name="cordova-plugin-streaming-media"/>

          Is your issue listed here?

          Issues · nchutchind/cordova-plugin-streaming-media · GitHub

           

          <plugin spec="https://github.com/shi11/RemoteControls.git"/>

          The docs say: "Cordova 3 plugin for iOS7". Seems to be very outdated.

           

          <plugin name="com.rd11.remote-controls" />

          Are you sure this plugin exists at npm at all?

           

          <plugin name="cordova-plugin-music-controls" />

          For Android and Windws, only. Not for iOS.

           

           

          ...but I can't get either one to work. I'm not sure what I may be doing wrong.

          Nobody here is, either, since you're not showing what exactly you are doing. For instance: did you include a reference to cordova.js? Are you waiting for the deviceready event to fire? Is your config found, read and parsed at all? Did you switch off Hydration when changing your config? Do you have any javascript errors in the console when debugging?

          • 2. Re: Locked screen audio controls
            georgej19520886 Level 1

            <plugin spec="https://github.com/AubreyHewes/cordova-background-audio.git"/>

            The README for this plugin says: "Phonegap Build: deprecated. no longer seems to work"

            I'm going to not use this one anymore because, while it does allow audio to play in the background, the audio can't be controlled.

            <plugin name="cordova-plugin-streaming-media"/>

            Is your issue listed here?

            Issues · nchutchind/cordova-plugin-streaming-media · GitHub

            This plugin seems to work as described but it doesn't display audio controls on a locked screen as I was hoping it somehow would.

            <plugin spec="https://github.com/shi11/RemoteControls.git"/>

            The docs say: "Cordova 3 plugin for iOS7". Seems to be very outdated.

            That may explain why I can't get this plugin to work.

            <plugin name="com.rd11.remote-controls" />

            Are you sure this plugin exists at npm at all?

            I'm removing this from config.xml

            <plugin name="cordova-plugin-music-controls" />

            For Android and Windws, only. Not for iOS.

            I did overlook this plugin not supporting iOS but I think this version is supposed to:

            <plugin spec="https://github.com/homerours/cordova-music-controls-plugin.git" />

            I can't get this to work either.

             

            I have a reference to phonegap.js. I was trying to test the plugin with the following code which is in an external script. Is there any reason this wouldn't work that you can tell?

             

            document.addEventListener("deviceready", onDeviceReady, false);

             

            function onDeviceReady() {

             

            MusicControls.create({

                track       : 'Time is Running Out',        // optional, default : ''

                  artist      : 'Muse',                     // optional, default : ''

                cover       : 'images/next-button.png',      // optional, default : nothing

                // cover can be a local path (use fullpath 'file:///storage/emulated/...', or only 'my_image.jpg' if my_image.jpg is in the www folder of your app)

                //           or a remote url ('http://...', 'https://...', 'ftp://...')

              isPlaying   : true,                           // optional, default : true

                dismissable : true,                         // optional, default : false

             

             

                // hide previous/next/close buttons:

                hasPrev   : true,      // show previous button, optional, default: true

                hasNext   : true,      // show next button, optional, default: true

                hasClose  : true,       // show close button, optional, default: false

             

             

              // iOS only, optional

              album       : 'Absolution',     // optional, default: ''

              duration : 60, // optional, default: 0

              elapsed : 10, // optional, default: 0

             

             

                // Android only, optional

                // text displayed in the status bar when the notification (and the ticker) are updated

                ticker    : 'Now playing "Time is Running Out"'

            }, function(){}, function(){});

             

            }//function

             

             

            Would you happen to know of any way I can get my app to function the way I'd like? All I want is for the user to be able to control audio from a locked screen.

            Thanks.

            • 3. Re: Locked screen audio controls
              VectorP Level 4

              I was trying to test the plugin with the following code which is in an external script. Is there any reason this wouldn't work that you can tell?

              Well, which part of your code is executed, and which part isn't?

              Are you sure the function onDeviceReady is executed at all?

              Do you get any javascript error messages while debugging?

              Where is the external script located, and did you whitelist that location?