Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use downloaded video files? #23

Open
Duncank opened this issue Jun 20, 2014 · 15 comments
Open

Use downloaded video files? #23

Duncank opened this issue Jun 20, 2014 · 15 comments

Comments

@Duncank
Copy link

Duncank commented Jun 20, 2014

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.

@gylippus
Copy link

gylippus commented Aug 5, 2014

Hey @Duncank,

I just did this for my app with files downloaded from FileTransfer with one change.

  1. 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

@winstef
Copy link

winstef commented Oct 28, 2014

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) ?

@gylippus
Copy link

@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();

@jaeger25
Copy link
Owner

Feel free to submit a pull request and I can merge any changes in

Sent from my Windows Phone


From: gylippusmailto:notifications@github.com
Sent: ‎10/‎28/‎2014 12:32 PM
To: jaeger25/Html5Videomailto:Html5Video@noreply.github.com
Cc: Matt Jaegermailto:matthew.jaeger@gmail.com
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:
#23 (comment)

@gylippus
Copy link

gylippus commented Jan 5, 2015

@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.

@odbol
Copy link
Contributor

odbol commented Jan 5, 2015

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...

@lalop
Copy link

lalop commented Aug 22, 2015

Hy @gylippus ,

I've found the same errors, did you finally found a solution ?

@gylippus
Copy link

@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.

@lalop
Copy link

lalop commented Aug 23, 2015

@gylippus I've reencoded my video via handBrake, I can play it now

@gylippus
Copy link

@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.

@lalop
Copy link

lalop commented Aug 23, 2015

I use the android preset, with 30fps, 1000kbps as average bitrate and profile baseline.
I can't share the video sorry

@sauvainr
Copy link

@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

@sauvainr
Copy link

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. :)

@ozooner
Copy link

ozooner commented Apr 4, 2016

@sauvainr, are you using entry.toNativeURL() with and just setting it as video src?

@sauvainr
Copy link

sauvainr commented Apr 4, 2016

Hi just the fileEntry.toURL() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants