I am trying to download a video and then play it using apache Cordova 3.4.0, but I do not know if I can use the video tag. There are several plugins that work to use a video tag, such as Html5Video , but must be present in the application folder for the video file. There are other plugins that use other players and download the file using the file path, but since downloading the file now uses the Html5 URLs and fullPath gives me the real path to the file system, it is really impossible to find out where the file was saved, or path to the video player. Is there a way to access the folder with the application folder and place the video so that it can be found in the cord and played?
This is what I still have, but I donβt know how to find the video.
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" /> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> <link rel="stylesheet" type="text/css" href="css/index.css" /> <title>Hello World</title> </head> <body> <div class="app"> <h1>Apache Cordova</h1> <div id="deviceready" class="blink"> <p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p> </div> <div id="video_container"> Loading Video... </div> </div> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="js/index.js"></script> <script type="text/javascript"> app.initialize(); document.addEventListener("deviceready", onDeviceReady, false); // device APIs are available // function onDeviceReady() { console.log('Requesting file system'); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); } function gotFS(fileSystem) { fileSystem.root.getDirectory("vids", {create: true}, gotDir); } function gotDir(dirEntry) { dirEntry.getFile("some_video.mp4", {create: true, exclusive: false}, gotFile); } function gotFile(fileEntry) { var localPath = fileEntry.fullPath; var localUrl = fileEntry.toURL(); console.log('Loaded local path: ' + localPath); console.log('Loaded local url: ' + localUrl); var fileTransfer = new FileTransfer(); var uri = encodeURI('http//site/with/video.mp4'); console.log('Downloading ' + uri + ' to ' + localPath); fileTransfer.download( uri, localUrl, function(entry) { console.log('download complete (path): ' + entry.fullPath); // Returns '/vids/some_video.mp4' console.log('download complete (url): ' + entry.toURL()); // Returns 'cdvfile://localhost/persistent/vids/some_video.mp4' document.getElementById('video_container').innerHTML = 'Downloaded Video path: ' + entry.fullPath + '<br />' + 'Downloaded Video url: ' + entry.toURL() + '<br />' + '<video width="100%" height="300" controls>' + '<source src="' + entry.toURL() + '" type="video/mp4">' + '</video>'; console.log('Wrote video player'); }, function(error) { console.log('download error source ' + error.source); console.log('download error target ' + error.target); } ); } function fail(error) { console.log('Error creating file [' + error.name + ']: ' + error.message); } </script> </body> </html>
The file loads correctly, but how can I get the full package after downloading it? Or move it to my cordova folder to put the url in the video tag?
!!! I found a solution !!!!
I worked with dev branches as described here .
source share