where to place local video files for android webview html5 hybrid app - webview

I am loading html page from asset folder to android webview, the html pages has video. Other images are loaded clearly but video is not loaded i mean not plays in app. Where to place the local video file? I tested by placing video files in asset folder and raw folder, but not plays video.
webView.loadUrl("file:///android_asset/index.html"); // load html file
video.src="file:///android_res/raw/test.mp4"; // load video file from raw folder
and
video.src="file:///android_asset/test.mp4"; // load video file from assets folder
Please help me, thanks in advance.

I placed video files in RAW folder and access video file in default.html file by following code:
video.src ="android.resource://ProjectPackageAame/raw/test";
video.type = "video/mp4";
video.load();
video.play();
It playes video like i want. Also added following line in AndroidManifest file.
android:hardwareAccelerated="true"
For playing video in full screen mode used showCustomView & hideCustomView method of WebChromeClient. What i have done is kept one Framelayout(customContainer) in my main.xml, and adding view received in showCustomView here, and removing it in onHide. Also hiding/showing webview accordingly.

Related

AVAggregateAssetDownloadTask seems to load m3u8 file twice

I am using AssetPersistenceManager from this Apple Sample : Using AVFoundation to play and persist http live streams
I create an AVURLAsset with a playlist master url, then call downloadStream(for:) with this asset, and the AVAggregateAssetDownloadTask complete download successfully !
It saves a folder named 286943_chapter_01_C955A55455AC0C4E.movpkg which contains the downloaded segments, my .m3u8 file and a StreamInfoBoot.xml file.
The StreamInfoBook.xml file contains references between local segment (or .frag) file and m3u8 segment URL.
However, those urls are signed and generated by Cloudfront. And some times, some URLs inside the .m3u8 file doesn't match URLs in StreamInfoBook.xml because of Expires parameter of cloudfrount.
So I think maybe AVAggregateAssetDownloadTask is calling the .m3u8 file twice : Once to save the .m3u8 and once to download segments and write StreamInfoBook.xml.
Does anyone already faced this issue ? What could I do to check if my Asset is playable offline or not ?
Do you have any suggestion ?
Here is an exemple of not matching segment URLs
In .m3u8 downloaded file :
https: //ezvoiznbov32f.cloudfront.net/file/265579/audio/chapter_08_10.mp3?Expires=1576159816&Signature=vfAYZ8ivP7yKeiranpba3R24gTSxexX4Nb1VjbDrR917pyFQqi2DMMMf8gi3LcueKXxv0FITprXzLXV62Py0Ph4nMxp8ixf5qG5sYnW1JcO74BxNfJE~DEurN~yQgczNBOK4b~bEXrDDZId1AweYJrgjZtjSoyUwAGXf~LA_&Key-Pair-Id=APKAAFEFNOSQQ34Q
In StreamInfoBook.xml file :
https: //ezvoiznbov32f.cloudfront.net/file/265579/audio/chapter_08_10.mp3?Expires=1576159817&Signature=PZ~tqOeIa3Vm26qKTFYU1LCGfvsWNpkUDMi3eFr~EhyRTLj66CDInSwfpoorYjl4Kl4B9eQ1W8ZzTlIMDGvs36wJ235JOszeov23IuIOzAJTlNw7zQYEd4Y1tq~nyZinpFoyDRGk0CelKOhH91Itb3rpQUeMN6lDhO-cq1X1OM_&Key-Pair-Id=APKAAFEFNOSQQ34Q
I'm testing with iOS 13.2
Well, answering myself :
After a very long time trying to make AVAggregateAssetDownloadTask works in background while the application is killed by the system, I finally switched to AVAssetDownloadTask.
Now everything is working perfectly ! It's like magic !
The difference between aggregate and normal tasks is in media selections. But I don't need it for now....

MonoGame cannot load a Song as a non-content file

I've created a game in XNA 4.0 and now want to port it to MonoGame. I'm using the exact same code for my LoadContent method as I did in the original game. However, MonoGame fails to load a song from the content folder and returns an error saying Could not load Example asset as a non-content file. I'm using the following line of code to do it.
Song song = songLoader.Load<Song>("Example");
The song is in the WMA format with a compiled XNB file in the same folder. Both files are set to "Copy if newer". How do I fix the problem?

play audio and video files in Cordova app that reside in iOS Documents directory

I have a Cordova application that I use to be able to link to mp3 and mp4 files relatively using a src like so:
../../Documents/videos/video.mp4
I just now updated my Cordova application to the latest version and these relative URLs don't work so I've been expermenting with other solutions.
It looks like if I use the cordova.file.documentsDirectory (iOS only) variable I can link to them that way but when I save references to these files in the database the GUID of the application changes and the URL is no longer valid when the app is rebuilt and relaunched.
I tried using cdvfile://localhost/persistent/ but this seems to only work for images and not video or audio files using HTML5 audio and video tags for playback.
Ultimately I could save the files with a variable that gets replaced at run-time but this is obviously not the preferred "solution." Something like [documentsfolder]/videos/video.mp4
How can I link to a persistent file location and have it work with images, audio files, and video files?
I would love to use the cdvfile url but have it work with mp3 and mp4 files.
Thank you.
You should be able to access any resource [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:#"www/[your path]"]

Cordova iOS: Load videos with downloaded html's and video files

I have the following issue:
I have an iOS Cordova Application.
The application download a zip file and decompress it in "cdvfile://localhost/persistent/content/myfolder" by ussing the following Cordova plugins: org.apache.cordova.file-transfer, org.apache.cordova.file and https://github.com/MobileChromeApps/zip.git
Inside the zip there is an "index.html" file with "video tags" on it.
I was able to succesfully load and execute the "index.html" file, but the video doesn't load.
I know that the video file was decompressed successfully because:
I check the file inside my iPad.
I embed the video in the index of the cordova app (not the downloaded one) in the following way and it works:
var videocontainer = document.getElementsByTagName('video')[0];
var videosource = document.getElementsByTagName('source')[0];
var newmp4 = cordova.file.documentsDirectory + 'content/myfolder/videos/myvideo.mp4';
videosource.setAttribute('src', newmp4);
videocontainer.load();
videocontainer.play();
But, the video is not loaded/played inside the downloaded HTML file. To understand what I'm doing, I have to develop an application that will be updated by downloading its contents from zips, and the contents includes pages with videos embeded on them. It works on PC and Android, but not in iOS.
I tried the following things:
Loading the page in "_self". The page is displayed but not the video.
Loading the page in an iframe. Same result.
Loading the page within an inAppBrowser (plugin). Same result.
Video tag with source src="videos/myvideo.mp4" (works in Web and Android). Same result.
Video tag with source src="./videos/myvideo.mp4" (works in Web and Android). Same result.
Video tag with source src= cordova.file.documentsDirectory + 'content/myfolder/videos/myvideo.mp4' (with JS, by passing the path in a query string, same path that works in the root index.html as I described before). Same result.
Video tag with source src= cordova.file.documentsDirectory + 'cdvfile://localhost/persistent/content/myfolder/videos/myvideo.mp4'. Same result.
All the combination of previous things. Same result....
Loading the downloaded resources in a DIV is not an option, because the resources (images, css, javascripts, audios, videos, etc.) are downloaded on other iOS device's folder: the app's Documents' folder (cdvfile://localhost/persistent/).
I thing I tried almost everything... Why is not trivial to play a video tag, inside an html, that are both in the app's Documents' folder???
:-(
EDIT 1: Cordova Version = 3.6.3
Solution Founded!!
In almost all the android and iOS examples, downloaded content is being executed from "cordova.file.documentsDirectory".
Then, when you link this content in a or (by using AJAX), everything works fine (CSS, images, links) but media tags ( and ).
Again, I dont know why, but almost all the examples downloads and unzip contents by using this path.
After several days being blocked with this issue (I found lots of forums where the devs have to modify all their projects by using plugins like Cordova Media, jaeger25 Html5Video, etc, etc), I tried by using the following path: "cordova.file.dataDirectory"
I download, unzip and execute the HTMLs from this path and everything works with no parsing/modifications to the HTML files (that in my case were thousands). 100% compability with and tags with relative sources' path in an IFRAME!!!!!!
I guess you code the video links into the index.html inside the zip you decompress on the device.
Those links need to get "updated" with some javascript parser, BEFORE you actually load or navigate to this page in your phonegap app.
If your example is caused in Android, you definetly need to include the HTML5 Video plugin here:
https://github.com/jaeger25/Html5Video
On iOS the tag will work for local files. But the links need to be absolute.
And the links will change if you recompile your app or reinstall it.
The files will be available, but the APP ID will have changed and the absolute path also.
Example of an iOS path:
/var/mobile/Applications/<application UUID>/Documents/path/to/file
Hope you solved your problem.

SWF file extraction

If I have a link to a SWF file - for example here http://redletterdaysb2b.co.uk/swf/our-video.swf
how can I extract it for use on another website?
I have downloaded the swf, but just get an error#2044 when I try and play it. does it need to go in some sort of wrapper?
thanks guys
You're trying to load a swf that in turn loads and displays a .flv using the FLVPlayback component. I'm guessing our-video.swf loads fine, but it probably keeps a relative reference to the .flv.
I can think of two ways to handle this:
Simple add a new FLVPlayback (or any other video player) on the other site but tell it to load the .flv file from the original site.
Try to copy the .flv file in the same folder as the new .swf on the new site.
With the FLVPlayback component there's another part that could cause the error: the skin which on the original site is here.
The #2024 IOError should also include an URL.
This is your best hint to how the our-video.swf is trying to load the .swf file (using a relative(./swf/redletterdays.swf) or an absolute(/swf/redletterdays.swf) path).
Based on this, if you decide to load the player from the original site (not just the .flv file), you can work out where to place the skin (i.e. in the in a folder named swf on the root of the new site)

Resources