'Media' Plugin not loading at runtime

24 views
Skip to first unread message

Jesse Monroy

unread,
Sep 21, 2018, 7:44:56 PM9/21/18
to phonegap

I picked up an app that had not picked up in 2+ years. (The last time I worked on it.)

 

To be clear, the app is not playing any audio. It has not since I picked the code back up. However, when I put it down the 2+ years ago, it was fully debugged and fully functional.

 

After two (2) days of working on the problem, I decided to scale back the problem to ONLY loading and playing an audio clip. The app in discussion is a single file app. (link below)

 

In additiion, I have spent two (2) days reworking my example code base for 'Phonegap Build' from 2+ years ago (link below). While working on this code, it reminded me to add CSP and the whitelist plugin, and make other minor corrects.

 

The result is that I have a new snippet of code to include in my test/debug cycle - namely 'typeof Media' and try/catch block.

 

Lastly, there appears to be NO syntax errors. Neither Firefox nor Chromium have reported any signifcant errors - save some minor CSS warnings.

 

THE PROBLEM APPEARS TO BE THAT 'Media' plugin IS NOT LOADING.

 

According to Mozilla documentaion for 'typeof' (link below), the call should return "function" or "object". The last debugging line to respond is 'status1'. The call of 'typeof Media' reponses with 'undefined'. The only exception for 'typeof' is using 'let' and 'const' in a 'block-scoped'

 

As such, I can only conclude - without additional information - that the 'Media' plugin is not loading at runtime.

Sorry, but posting code with this POS editor is not working.

------

problem app (source code): https://github.com/jessemonroy650/pgb-example-core-media

problem phonegap build: https://build.phonegap.com/apps/3306836/builds

links to reworked example code base: http://pgb-examples.wikidot.com/start

'typeof' documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

 

Again, the 'status2' indicator, listed below when calling 'typeof Media', is 'undefined'.


------


    function onDeviceReady() {
        alert("device ready.");
        document.getElementById('isCordovaApp').innerHTML  = isCordovaApp(window.cordova);
        document.getElementById('isKnownDevice').innerHTML = isKnownDevice(navigator.platform);
        document.getElementById('appVersion').innerHTML    = app.version;
        if (isCordovaApp(window.cordova)) {
            deviceStuff();
            //
            // Play some sound
            //
            document.getElementById('status0').innerHTML = "loading";
            document.getElementById('status1').innerHTML = typeof Media;
            //document.getElementById('status2').innerHTML = Object.is(Media, Media);
            //document.getElementById('status3').innerHTML = auto instanceof Media;

            //return;
            //var my_media = new Media("fanfare3.ogg", function() {document.getElementById('status').innerHTML = "success"; }, function(err) {document.getElementById('status').innerHTML = "error-fail<br>" + err; } );
            var my_media = {};
            try {
                my_media = new Media("fanfare3.ogg");
            } catch (e) {
                //junky = e instanceof ReferenceError;
                junky = e.message + "<br>";
                junky = junky + e.name + "<br>";
                junky = junky + e.fileName + "<br>";
                junky = junky + e.lineNumber + "<br>";
                junky = junky + e.columnNumber + "<br>";
                junky = junky + e.stack + "<br>";
                document.getElementById('status2').innerHTML = junky
            }
            //document.getElementById('status2').innerHTML = typeof my_media;
            //document.getElementById('status').innerHTML = "loaded";
            //my_media.play();
            //document.getElementById('status').innerHTML = "playing => " + "fanfare3.ogg";
        }
    }
    // The 'DOMContentLoaded' event fires before the 'deviceready'
    document.addEventListener('DOMContentLoaded', onDOMContentLoaded, false);
    // Wait for PhoneGap to load
    document.addEventListener("deviceready", onDeviceReady, false);

Jesse Monroy

unread,
Sep 24, 2018, 4:00:21 AM9/24/18
to phonegap
Okay. I got the plugin to load.
It turns out that Phonegap Build does NOT give you a warning if something goes wrong. If "Build" decides it can not use the plugin, it will simply put a message in the debug log and NOT install the plugin.

That is correct. Phonegap Build will complete the construction of an APK and if it happened to not install the plugin, it will not tell you. VERY VERY frustrating.

Needless to say, I will inform the Phonegap Build team that this is pure BS.

I still need to get some audio. I will post if I need help with that.

Thanks Guys
Jesse


On Friday, September 21, 2018 at 5:44:56 PM UTC-6, Jesse Monroy wrote:

I picked up an app that had not picked up in 2+ years. (The last time I worked on it.)

 

...
Reply all
Reply to author
Forward
0 new messages