2

I have a problem with a mobile app that I'm developing in HTML, CSS and Javascript to compile with Phonegap.

What happens is that so far the videos have been playing from an iframe on Vimeo, but now it is necessary that they can be stored locally on the phone for offline playback.

Does anyone have an idea of ​​how could I do that? I do not know if with any API or with the native android player could be done.

Thank you very much for any help.

Andrés Girón
  • 97
  • 1
  • 11
  • you can look into sd card libs, but this task is not going to be easy – dandavis Feb 01 '17 at 21:28
  • I don't know what exactly you're asking for? At a first glance, Vimeo mentions an API wich should be able provide you all information you need to locate *(get/build the url)* the actual video-file that needs to be stored to disk. And [Download files and store them locally with Phonegap/jQuery Mobile Android and iOS Apps](//stackoverflow.com/q/6417055/6567275) is the result of a 2 second google search for "phonegap save video to disk" – Thomas Feb 01 '17 at 23:10

1 Answers1

2

The following two conditions must be met to gain access to the .mp4 video files.

  1. You uploaded the videos (so you own them)
  2. You are a PRO Vimeo user.

I haven't worked with Phonegap before but I have some perspective on Android. The easiest way to get the URL via Android code is through the the Vimeo API. There is a Java library for interacting with the Vimeo API here which will allow you to request Video objects for the videos you own (probably by hitting the /me endpoint).

This section of the README.md should be helpful in understanding how to get access to fields on the Video object (but you should read the whole thing to get it set up).

Once you have a Video object, you can access the download field which is an array of VideoFiles which will contain a link to an .mp4 file that you can pass to any file downloader. The code would look something like below:

Video myVideo = ...// Some video retrieved from the API
if(mVideo == null || mVideo.download == null || mVideo.download.isEmpty()) {
    // Throw an error
}
VideoFile videoFileToDownload = mVideo.get(0);
// The url to the mp4 file
String videoFileUrl = videoFileToDownload.mLink;
download(videoFileUrl); // You'll need to make a method to download

The two holes are 1) how to get a video and 2) how to download a file. The first question can be answered by the vimeo-networking-java library's README. The second question should be easy enough to find a solution on Google (downloading a file given a link to an .mp4 file).

Kyle Venn
  • 4,597
  • 27
  • 41