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);
I picked up an app that had not picked up in 2+ years. (The last time I worked on it.)
...