12 Replies Latest reply on Feb 20, 2018 12:39 PM by Aquila51

    plugin unsupported: org.apache.cordova.media

    Aquila51

      I'm trying to play mp3 files, using the HTML5 audio tag. The mp3 files are not a list, it's a file chosen from user, and can be any of the 75 different sounds, so that means it's a variable file. I was constructing the audio via document.createElement('audio') and there is no way for me to go around. Is there any suggestion of how to deal with this?, by the way the title is the error that appears when trying to generate .apk file.

      Thanks

      Ovidio

        • 1. Re: plugin unsupported: org.apache.cordova.media
          jcesarmobile_ Adobe Community Professional

          apache.cordova.media changed to cordova-plugin-media long time ago (years).
          The old format with dots is no longer supported, switch to use cordova-plugin-media

          • 2. Re: plugin unsupported: org.apache.cordova.media
            Aquila51 Level 1

            Sorry jcesarmobile, I still get the red bar message of plugin unsupported, I put that in my config file as this:

            <gap:plugin name="cordova-plugin-media" />

            Is it right or not? if it's right, what should I do next?; if it isn't, what should I do next?

            Thanks for your time to reply

            Have a nice day

            • 3. Re: plugin unsupported: org.apache.cordova.media
              jcesarmobile_ Adobe Community Professional

              Did you remove the org.apache.plugin.media entry first?

               

              This one works fine for me

              <plugin name="cordova-plugin-media" spec="~5.0.2" />

               

              Make sure you don't have any plugin entry with org.apache.plugin

              • 4. Re: plugin unsupported: org.apache.cordova.media
                Aquila51 Level 1

                Hi jcesarmobile, there isn't any entry with dots, even I copied what you suggested, and still not working. That is because I'm using HTML5, CSS and JS? on my computer is just fine, works perfectly, but testing it on a real android device downloading the apk file, ir crashes.

                 

                Thanks

                • 5. Re: plugin unsupported: org.apache.cordova.media
                  jcesarmobile_ Adobe Community Professional

                  But you have been able to build the .apk, right? so it's a different problem now

                  • 6. Re: plugin unsupported: org.apache.cordova.media
                    Aquila51 Level 1

                    Hi, I'm always been able to build apk file, and tested in a real android device, the only problem is that the sound is not playing,

                    using this <plugin name="cordova-plugin-media" spec="~5.0.2"/>, is there something else that I should put in config file? I'm new to android dev some maybe I'm missing something.

                    The app works perfect in my computer.

                    Thanks

                    Have a nice day

                    • 7. Re: plugin unsupported: org.apache.cordova.media
                      jcesarmobile_ Adobe Community Professional

                      Well, in your question you said

                      "by the way the title is the error that appears when trying to generate .apk file."

                       

                      By trying I understand you weren't able to build it.

                       

                      Anyway, if the plugin is installed, you have to use the plugin API instead of an audio tag.
                      To play an audio you have to do it like this:

                       

                       

                      var myMedia = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");

                      myMedia.play();

                      • 8. Re: plugin unsupported: org.apache.cordova.media
                        Aquila51 Level 1

                        OK, this is long story...

                        I'm not playing an mp3 from the web, I want to play from my own app, I made this changes:

                        You say this:

                        var myMedia = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");

                        myMedia.play();

                        I changed it to this:

                        var myMedia = new Media(src, onSuccess);

                        myMedia.play();

                        where src it's a variable containing the Uri of the mp3 file, according to console.log it's getting the right mp3, but still does not play it (!?)

                        • 9. Re: plugin unsupported: org.apache.cordova.media
                          jcesarmobile_ Adobe Community Professional

                          Yeah, that was an example to show you how to use it.

                           

                          Is your file bundled in the www folder? or is it recorded? or is it downloaded?
                          Can you provide your real code used? specially the uri

                           

                          And in your example you have onSuccess, did you create an onSuccess function? try putting the play there
                          Also try adding the onError callback as it might give you more information about what is failing

                          • 10. Re: plugin unsupported: org.apache.cordova.media
                            Aquila51 Level 1

                            Hi, good morning!

                            Ok, my mp3 files ares located as: www-->res-->raw-->*.mp3

                            The mp3 file is read from a DB which contains the actual mp3 file, this is the code :

                            Javascript

                            sounda = 'res/raw/'+data.rows.item(i).ealarm;

                            src=sounda+'.mp3';

                            var myMedia = new Media(src, onSuccess, onError);

                            function onSuccess(){

                            console.log("Playing Audio");

                            myMedia.play();

                            }

                            function onError (err) {

                            console.log("An error occurred: " + err.code);

                            }

                            the error I'm getting it says that Media is not defined?

                            My config file:

                            <plugin name="cordova-plugin-media" spec="~5.0.2"/>

                            <feature name="Media">

                            <param name="android-package" />

                            </feature>

                            If I take the feature out, does not create the apk, if I leave it back it does, tested with value="cordova-plugin-media", it creates the apk, but still no sound, tested without it, same situation...

                             

                            So this make me think that something is missing somewhere, an installed plugin, or an extra definition in config, or something in both places

                            Thanks for your help, have a nice day

                            • 11. Re: plugin unsupported: org.apache.cordova.media
                              jcesarmobile_ Adobe Community Professional

                              Have you set a CLI version for your app? if not, default one is used, 6.5.0 at the moment, which is not compatible with latest version of media plugins.

                              You will have to set the CLI to 7.1.0 or newer or downgrade the plugin to 3.0.1

                              • 12. Re: plugin unsupported: org.apache.cordova.media
                                Aquila51 Level 1

                                Hi, I made all kinds of combinations to see the difference among all of them, and the best result is this, in my config file:

                                <preference name="phonegap-version" value="cli-6.5.0" />

                                <plugin name="cordova-plugin-media" spec="^3.0.1" />

                                with phonegaap-version 7.1.0 errors all over

                                finally no apk file generated

                                LOG:

                                Fetching plugin "cordova-plugin-media@^3.0.1" via npm

                                Installing "cordova-plugin-media" at "3.0.1" for android

                                Fetching plugin "cordova-plugin-file@^4.0.0" via npm

                                Installing "cordova-plugin-file" at "4.3.3" for android

                                Fetching plugin "cordova-plugin-compat@^1.0.0" via npm

                                Installing "cordova-plugin-compat" at "1.2.0" for android

                                 

                                The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if your application needs any changes in its config.xml.

                                 

                                If this is a new application no changes are required.

                                 

                                If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

                                 

                                  "<preference name="AndroidPersistentFileLocation" value="Compatibility" />"

                                 

                                to config.xml in order for the application to find previously stored files.

                                  

                                Plugin dependency "cordova-plugin-compat@1.2.0" already fetched, using that version.

                                Dependent plugin "cordova-plugin-compat" already installed on android.

                                 

                                This is the first time I'm trying to run the app, so, nothing to do with persistent file, not yet generated...?!

                                Thanks for your help and patience, please remember that I'm new to this technology, so may there are things I'm missing,

                                my platform installation steps were:

                                Java JDK

                                Android SDK

                                Apache ANT

                                NodeJS

                                npm install -g cordova

                                phonegap build uploading  a zip file

                                all this based on windows 10