Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-24400

Android: Download video and save it to the Device's Gallery

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: None
    • Resolution: Fixed
    • Affects Version/s: Release 6.0.1
    • Fix Version/s: Release 6.1.0
    • Component/s: Android
    • Labels:
    • Environment:

      Android 6.x

    • Story Points:
      5
    • Sprint:
      2017 Sprint 04 SDK

      Description

      Issue description:

      We want to be able to download a video file from our servers to the device and save it on the gallery (upon user's approval). On iOS we accomplish this by this code:

      var fileName = 'fileToDownload.mp4', 
             saveToGalleryFlag = true, 
             videoUrl = 'http://somedomain.com/fileToDownload.mp4';
       
      var xhr = Titanium.Network.createHTTPClient({
      		onload : function() {
       
      			var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, fileName);
       
      			// write to the file
      			f.write(this.responseData);
       
      			if (saveToGalleryFlag) {
      				var blob = f.read();
       
      /* According to Titanium docs, this does not save Videos on Android */
      				Titanium.Media.saveToPhotoGallery(blob, {
      					success : function(e) {
      						console.log('-> SUCCESS');
      					},
      					error : function(e) {
      						console.log('-> ERROR', e)
      					}
      				});
      			}
      		},
      		timeout : 10000
      	});
       
      xhr.open('GET', videoUrl);
      xhr.file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, fileName);
      xhr.send();
      

      Expected Result:

      Download videos into Android gallery/ file system upon users approval.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                vvazquezmontero Victor Vazquez Montero
                Reviewer:
                Andy Waldman
                Tester:
                Lee Morris (Inactive)
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration