Cordova/Phonegap 1.6 media Example - javascript

i dont want to mention that Phonegap has gone sloppy recently...
but I'm trying to use the Media example taken AS IS from their website
using Xcode 4.3..
beside replacing phonegap.js with cordove.js, duh, i got a lot of errors:
ERROR: Method 'create:withDict:' not defined in Plugin 'Media'
FAILED pluginJSON = {"className":"Media","methodName":"create","arguments":["Media1","9476cdcf-7f6c-5e05-a022-fa488e8bed40","http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3"]}
Will use resource 'http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3' from the Internet.
ERROR whitelist rejection: url='http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3'
ERROR whitelist rejection: url='http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3'
ERROR whitelist rejection: url='http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3'
Unable to download audio from: http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3
Failed to initialize AVAudioPlayer: (null)
i just used their example as is, and i'd expect it works...
what should i change? is that a xcode issue maybe??

"whitelist rejection"
Basically, you need to add any external URLs you want to access to the "whitelist" (i.e.: the ExternalHosts key in the Cordova.plist file).
See this answer:
https://stackoverflow.com/a/8045541/878602
...or the PhoneGap Wiki FAQ for iOS:
http://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ

it looks to me that you can't download the mp3. Can you enter that url in the iphone's safari and download the mp3?
Do you have your own webserver to try maybe? You could see the logs and see if it gets there at all.
BTW I just used the same example yesterday in Android and it works for me.

If you may updating the cordova. They have changed many function names.
For example if you are using the startAudioRecord function in previous versions. Currently they have changed it as startRecord.
Likewise they have changed many internal function names.
Just open your cordova.js. check appropriate function and function name exists.

Related

browser.alarms is undefined using webextension-polyfill

I'm trying to create an alarm using browser.alarms API for web extensions.
To make the extension cross-browser, I am using webextension-polyfill and testing on Chrome.
My code to create an alarm within a background script is shown below:
browser.alarms.create('spline-items-notification', {
periodInMinutes: 1
});
However, when I attempt to run this extension, I always get an error:
Uncaught TypeError: Cannot read property 'create' of undefined
I am loading webextension-polyfill before the background script in manifest.json, and other interfaces work, like browser.notifications.
I would like to know how to fix this if possible. Thank you.
alarms
To use this API you need to have the "alarms" permission.
Does the manifest.json have the "alarms" permission?
I think this a bug with webextension-polyfill, but I opened a pull request that should fix it.

PDF.js not working when deploying to different Server in IE

I have a local IIS site where i developed some code with PDF.js. There it worked fine to load a specific PDF and read the text contents from it.
Then I copied everything to the a library in a SharePoint Server (thats the only difference, IIS vs SharePoint) and changed all references. The code does not throw any Errors, with debugging level info it just prints
Info: Cannot use postMessage Transfers
to the console. Adding a console.log line into the PDF.js catch block of the promise did not result in any new information. It doesn't even get to the first logging inside the then:
var pdfobj = PDFJS.getDocument(docPath);
pdfobj.then(function (pdf) {
console.log(pdf);
any ideas?
EDITS: Updated from PDF.JS 1.1 to 1.2
There are not many error logs in PDF.js. I accidently hardcoded a wrong URL where even the server is non existent... and no error log, not even the then(...).catch(...) is called?
It is working now in Firefox but not in IE and I cannot see any reason for this. The Info message about Cannot use postMessage Transfers is also only displayed in IE (using IE 11).
It does work now. I am not sure what I did to fix it, but I will update this answer when I know. I think it has something to do with the directory structure of the PDF.js files. Previously I just uploaded all JS files (there were no errors though).
Still there is no exception handling when the PDF does not exist.

Access is Denied on IE11 in AngularJS

Every development pipeline has 2 parts. FIRST to work hard and develop the application. SECOND to work harder and make it compatible with the great arrogant IE.
We have an AngularJS (v1.3.13) application without any server side code developed in Webstorm. We are making REST calls to service. Our application works fine on Chrome and Firefox without any Console errors. However when we try to open the page in IE11 or IE9 (not tried IE10), our page doesn't load. Console suggests we have 2 errors. One of them is Access is Denied on
xhr.open(method, url, true);
in angular.js.
There are number of posts on internet and none seems to be working. This is what I have tried.
Hosting app in IIS with changed Handler Mappings to support Cross Domain calls on an Application pool of .Net v4.0 (as suggested by a Senior)
Tried to disable to cache for HTTP requests.
Adding Domain in trusted site category and also adding locahost/IP to local intranet.
Changing request type to JSONP and trying to add Access-Control-Allow-Origin (with value of *) to headers.
Changing IE settings to allow Cross Domain calls.
Error is still chasing us. Even my colleagues have tried the same on their machines ending up with similar blow. Is there anyone to suggest me something on this.
It may be CORS and I may need to go for xdr (XDomainRequest) but not sure how to use it as error is in angular.js. I am certainly no expert on this so please suggest.
Screen shot of the error:
IE shows another error:
[$injector:nomod] Module 'ngLocale' is not available!
You either misspelled the module name or forgot to load it.
If registering a module ensure that you specify the dependencies
as the second argument.
http://errors.angularjs.org/1.2.16/$injector/nomod?p0=ngLocale which I am ignoring for now.
Please suggest me something on this.
Thanks.
I switched from 1.3.4 to 1.4.8 and that did the trick. No more Angular Access Denied in I.E. (Microsoft Edge 25 2015). I don't know why.
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-route.js/1.4.8/angular.min.js"></script>
Access is Denied on IE11 in AngularJS error have a solution on this link
I also got the same error while downloading Image from IE11. I have just added the following line in my code and It works.
window.navigator.msSaveBlob(blob, paramDataObject.fileName);
or
window.navigator.msSaveOrOpenBlob(blob, paramDataObject.fileName);
Have you tried xdomain? https://github.com/jpillora/xdomain it's a pure javascript CORS alternative.
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob);
}
else {
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
}
Setting window.location or window.open in AngularJS gives "access is denied" in IE 11

Recover javascript logs and errors on Internet Explorer without F12 tool

The main idea is to run a random page on Internet Explorer and get javascript errors and logs.
Is there a way to recover javascript console logs and execution error
from a random web page without accessing the F12 tool on Internet
Explorer?
I found that with Chrome based browser, you can get it on your AppData file log by adding --enable-logging --v=1 args when launching.
Any solution with any language are welcome.
Thank you for your answer.
NOTE :
random page on Internet Explorer means that I do not have the access on the source code.
Basic solution to this would be:
1. Use Exception Handling to catch the errors.
2. Log errors in a Global Array
3. Log the errors in a file using Blob and URL.createObjectURL. All recent browsers support this.
Have you considered using a Bookmarklet that:
Overrides window.console.log and window.console.error (to intercept messages)
Logs incoming messages somewhere using createObjectURL?
Or you could use something like firebuglite and auto-enable it like this:
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js">
{
overrideConsole: false,
startInNewWindow: true,
startOpened: true,
enableTrace: true
}
</script>
More instructions are here: http://getfirebug.com/firebuglite
If the F12 tool is not of your interest, then what about the Event Viewer? Open Event Viewer from Control Panel -> System and Security -> Administrative Tools -> Event Viewer.‌ Then select the log Applications and Services Logs\Internet Explorer.
By default no events are being logged for Internet Explorer, to enable them create a new DWORD registry value named Feature_Enable_Compat_Logging under the following registry key:
HKCU\SOFTWARE\Microsoft\Windows\Internet Explorer\Main \FeatureControl
and set the registry value to 1.
Check the logs you get to see if it's what you're looking for.
One idea would be to write a browser extension which listens for window.onerror and writes to a file. Definitely not as elegant as the Chrome solution, but it would work fairly well.
Using local proxy might be a good one-time solution.
Charles web debugging proxy app has nice UI and it allows to replace any response with local resource.
So basically you'll need:
Download one any of the js files used on target page
add any code you wish to saved version
set up Charles to serve you your local version instead of remote one
You might try Fiddler. It's got its own logging and has amazing inspection power. It won't capture IE specific errors, since it's at a different layer, but it will definitely get you any code that's coming over the wire.

Uncaught Error: SECURITY_ERR: DOM Exception 18 when I try to set a cookie

I get the following error in Chrome's developer tools window when I try to set a cookie using this jQuery plugin:
Uncaught Error: SECURITY_ERR: DOM Exception 18
What does this error mean and how can I fix it? I get the same error when I use this jQuery plugin.
You're most likely using this on a local file over the file:// URI scheme, which cannot have cookies set. Put it on a local server so you can use http://localhost.
I also had this issue while developping on HTML5 in local.
I had issues with images and getImageData function.
Finally, I discovered one can launch chrome with the --allow-file-access-from-file command switch, that get rid of this protection security.
The only thing is that it makes your browser less safe, and you can't have one chrome instance with the flag on and another without the flag.
You can also "fix" this by replacing the image with its inline Base64 representation:
img.src= "data:image/gif;base64,R0lGODlhCwALAIAAAAAA3pn/ZiH5BAEAAAEALAAAAAALAAsAAAIUhA+hkcuO4lmNVindo7qyrIXiGBYAOw==";
Useful, when you do not intend to publish the page on the web, but instead use it on local machines only.
Faced with the same situation playing with Javascript webworkers. Unfortunately Chrome doesn't allow to access javascript workers stored in a local file.
One kind of workaround below using a local storage is to running Chrome with --allow-file-access-from-files (with s at the end), but only one instance of Chrome is allowed, which is not too convenient for me. For this reason i'm using Chrome Canary, with file access allowed.
BTW in Firefox there is no such an issue.
This error pops up, if you try to create a web worker with data URI scheme.
var w = new Worker('data:text/javascript;charset=utf-8,onmessage%20%3D%20function()%20%7B%20postMessage(%22pong%22)%3B%20%7D'); w.postMessage('ping');
It's not allowed according to the standard: http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#dom-worker
I had this issue when using the history API.
window.history.pushState(null, null, URL);
Even with a local server (localhost), you want to add 'http://' to your URL so that you have something similar to:
http://localhost...
I wasn't completely happy by the --allow-file-access-from-files solution, because I'm using Chrome as my primary browser, and wasn't really happy with this breach I was opening.
Now I'm using Canary ( the chrome beta version ) for my development with the flag on.
And the mere Chrome version for my real blogging : the two browser don't share the flag !
One can also receive this error if using the new (so far webkit only) notification feature before getting permission.
First run:
<!-- Get permission -->
<button onclick="webkitNotifications.requestPermission();">Enable Notifications</button>
Later run:
// Display Notification:
window.webkitNotifications.createNotification('image', 'Title', 'Body').show();
The request permission functions needs to be triggered from an event caused by the user, otherwise it won't be displayed.
I was been getting that error in mobile safari when using ASP.NET MVC to return a FileResult with the overload that returns a file with a different file name than the original. So,
return File(returnFilePath, contentType, fileName);
would give the error in mobile safari, where as
return File(returnFilePath, contentType);
would not.
I don't even remember why I thought what I was doing was a good idea. Trying to be clever I guess.

Categories