Html5Video
Html5Video copied to clipboard
Use downloaded video files?
Is it possible to use video files that have been downloaded to the device later? They end up in a data-folder or a folder on the sdcard, but not inside the app package itself.
Hey @Duncank,
I just did this for my app with files downloaded from FileTransfer with one change.
- In HTML5Video.java Change like 29 to point to your download location. For me I was using cordova.file.dataDirectory:
convertedVideos.put(tagNames.getString(i), "file:///data/data/packagename.something.com/files/" + video[0] + ".mp4");
The plugin normally also tries to use a videoid int, but I am using video[0] for the file name instead. Granted I have only been needing to initialize one video at a time so I will let you know what happens when I try multiple.
Let me know if this helps at all.
Using a downloaded file location also makes it work on Android 4.4+ !!!!!!! Note: @jaeger25
Hey @gylippus is your change works only for Android 4.4+ ?
I'm trying to get it to work on 4.2.2 but since the Webview does not allow file:/// I'm wondering how to play a video from the download location (cordova.file.dataDirectory) ?
@winstef I used this solution for all version. I actually found though that certain devices (like HTC Desire and some Samsung) would not even allow using mediaPlayer from downloads in cordova.file.dataDirectory although almost every other device would.
I ended up using cordova.file.externalDataDirectory in the end.
The last hurdle that I'm still not 100% past is finding the absolute perfect codec combination to use in Handbrake of ffmpeg to cover 100% of devices with that as well.
Just as a caveat, one other change I had to make for the HTC Desire was to set the file permissions manually after downloading via the download method of FileTransfer.java
Log.d(LOG_TAG, "Download file:" + sourceUri);
//HTC Desire and some other devices need the following permission
file.setReadable(true, false);
FileProgressResult progress = new FileProgressResult();
Feel free to submit a pull request and I can merge any changes in
Sent from my Windows Phone
From: gylippusmailto:[email protected] Sent: 10/28/2014 12:32 PM To: jaeger25/Html5Videomailto:[email protected] Cc: Matt Jaegermailto:[email protected] Subject: Re: [Html5Video] Use downloaded video files? (#23)
@winstef I used this solution for all version. I actually found though that certain devices (like HTC Desire and some Samsung) would not even allow using mediaPlayer from downloads in cordova.file.dataDirectory although almost every other device would.
I ended up using cordova.file.externalDataDirectory in the end.
The last hurdle that I'm still not 100% past is finding the absolute perfect codec combination to use in Handbrake of ffmpeg to cover 100% of devices with that as well.
Just as a caveat, one other change I had to make for the HTC Desire was to set the file permissions manually after downloading via the download method of FileTransfer.java
Log.d(LOG_TAG, "Download file:" + sourceUri);
//HTC Desire and some other devices need the following permission
file.setReadable(true, false);
FileProgressResult progress = new FileProgressResult();
Reply to this email directly or view it on GitHub: https://github.com/jaeger25/Html5Video/issues/23#issuecomment-60816965
@odbol & @Duncank Have either of you run into any issues with videos playing on some Samsung devices with custom ROMs?
For some of our users the videos just show up as white boxes and nothing else. I gave in and bought a Samsung S3 and installed Dirty Unicorns 4.4.4 [Final KitKat Version].
When I review the Logcat logs I am getting the following error (the same error repeats about 20 times before failing on the last line) which point to an OpenGL issue which I haven't been able to find a workaround for yet:
01-05 11:32:14.604: E/MediaPlayer(4560): Should have subtitle controller already set
01-05 11:32:14.669: E/chromium(4560): [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x5e458860]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
01-05 11:32:14.669: E/chromium(4560): [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x5e458860]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
01-05 11:32:14.669: E/chromium(4560): [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x5e458860]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
01-05 11:32:14.714: E/chromium(4560): [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x5e458860]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
01-05 11:32:14.714: E/chromium(4560): [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x5e458860]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
01-05 11:32:15.999: E/MediaPlayer(4560): Should have subtitle controller already set
01-05 11:32:15.999: D/AudioPlayer(4560): Send a onStatus update for the new seek
01-05 11:32:16.084: E/chromium(4560): [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x5e458860]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
01-05 11:32:16.084: E/chromium(4560): [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x5e458860]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
01-05 11:32:16.334: E/chromium(4560): [ERROR:logger.cc(46)] Too many GL errors, not reporting any more for this context. use --disable-gl-error-limit to see all errors.
Sorry I've never seen that before, and I've tested this on a SGS3 with stock 4.3 ROM. Seems like it's probably a custom ROM issue...
Hy @gylippus ,
I've found the same errors, did you finally found a solution ?
@lalop unfortunately not. Would love to find out a way to though. The only progress I was able to make on this was to at least test and confirm that it does indeed work fine if the app is using Crosswalk. We are going to work on trying to improve the error handling for the plugin and hopefully that might be able to shed some light. Will share anything we do find.
@gylippus I've reencoded my video via handBrake, I can play it now
@lalop, very interesting, any chance you can share the Handbrake settings that you used? Maybe even the video. Would be interested to it on the device we had the custom ROM on.
I use the android preset, with 30fps, 1000kbps as average bitrate and profile baseline. I can't share the video sorry
@gylippus I attempt to play downloaded files by following your way:
- Change HTML5Video.java to point to cordova.file.externalDataDirectory
- Change FileTransfer.java with file.setReadable(true, false);
Unfortunately the file still dont playback. Have you made other changes? Thanks in advance
I finally make it work by.. not using html5video at all.
So for app which plays videos in a html tag and requires offline playback:
- Download the files with fileTransfer plugin into cordova.file.externalDataDirectory. And
- Add the line file.setReadable(true, false); to FileTransfer.java line 820 as discribed by @gylippus
Hope this save hours of research for someone else. :)
@sauvainr, are you using entry.toNativeURL() with and just setting it as video src?
Hi just the fileEntry.toURL() method.