Skip to content Skip to sidebar Skip to footer

"undefined" Result Using FileOpener Phonegap Android And Failed To Open Video File?

i have downloaded plugin FileOpener and added in m,y project like this:

Solution 1:

 <!DOCTYPE html>
 <html lang="en"  dir="ltr">
 <head>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width,  user-scalable=no">
<title>sample</title>
<script src="js/cordova.js"></script>
<script src="js/video.js"></script>
<script src="js/fileopener.js"></script>
<script src="js/ADD_ANY_JQUERY.MIN.JS"></script>
<script>
   function openFile(filePath)
  {
     window.plugins.fileOpener.open(filePath);
  }
</script
</head>
<body>
<div data-role="page" data-theme="a" class="my-page" id="video">
<img src="img/b_img1.png" onclick="openFile('file:///android_asset/www/videos/1974.mp4')"/>
</div>
</body>

Edited Fileopener.js will be like this:

cordova.define("cordova/plugin/fileopener",
  function(require, exports, module) {
    var exec = require("cordova/exec");
    var FileOpener = function () {};

FileOpener.prototype.open = function(url) {
    exec(null, null, "FileOpener", "openFile", [url]);
};

FileOpener.prototype.setTAG = function(tag) {
    exec(null, null, "FileOpener", "setTAG", [tag]);
};
var fileOpener = new FileOpener();
    module.exports = fileOpener;

});
/**
 * Load Plugin
 */
if (!window.plugins) {
    window.plugins = {};
}
if (!window.plugins.fileOpener) {
    window.plugins.fileOpener = cordova.require("cordova/plugin/fileopener");
}

"js/ADD_ANY_JQUERY.MIN.JS" in this line add a any jquery.min.js

Lastly check that Cordova.js folder is in your js folder of your application.. And let me know if it is not working what's your logcat saying...


Solution 2:

i was using cordova 2.9.0 , jquery 1.9.1 ,jqm-1.3.2 and android-sdk-version:14 after adding code i was getting error:logcat is:

01-06 19:36:53.132: D/PluginManager(9420): exec() call to unknown plugin: FileOpener 
 01-06 19:36:53.202: D/CordovaLog(9420): file:///android_asset/www/js/fileopener.js: Line 20 : Class not found     
01-06 19:36:53.202: I/Web Console(9420): Class not found at file:///android_asset/www/js/fileopener.js:20 

the solution of this problem is i have done mistake in config.xml and in plugin.xml: config.xml replace this:

 <feature name="videoplayer">
        <param name="android-package" value= "com.adidas.football.app.videoPlayer.VideoPlayer"/>
    </feature>

with:

  <feature name="VideoPlayer">
        <param name="android-package" value= "com.adidas.football.app.videoPlayer.VideoPlayer"/>
    </feature>

plugin.xml replace this:

<plugin name="videoplayer" value= "com.adidas.football.app.videoPlayer.VideoPlayer"/>

with:

 <plugin name="VideoPlayer" value= "com.adidas.football.app.videoPlayer.VideoPlayer"/>

a minor mistake of CAPITAL LETTER but it removes all error and finally i have no error except last one alert which i added in my edited question "cannot play video"


Post a Comment for ""undefined" Result Using FileOpener Phonegap Android And Failed To Open Video File?"