Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-426

camera.getPicture ignores mediaType in 1.5

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.0
    • 1.6.0
    • cordova-android
    • Android 2.1 (Virtual), Android 3.1 (Motorolla Xoom). Built from Windows 7.

    Description

      Hi,
      I was using getPicture to upload videos, but when I upgraded to cordova-1.5.0 I noticed that the only files that I was able to select where pictures instead of videos.

      The Call I was doing is this one: navigator.camera.getPicture(onVideoURISuccess, onVideoURIFail,

      { quality:50, mediaType: Camera.MediaType.VIDEO, destinationType: _destinationType.FILE_URI, sourceType: source}

      );

      When I was using 1.4.1 the result was getting a list of videos from the gallery. Since I installed 1.5.0 I could only select images.

      A code similar to what I was using is this one:
      http://stackoverflow.com/questions/8940058/phonegap-crash-when-using-file-transfer-for-uploading-video-larger-than-15mb

      <!DOCTYPE html>
      <html>
      <head>
      <title>Video Uploader</title>
      <meta name="viewport" content="width=device-width, initial-
      scale=1">
      <link rel="stylesheet" href="master.css" type="text/css" />
      <script type="text/javascript" charset="utf-8"
      src="phonegap-1.3.0.js"></script>
      <script type="text/javascript" charset="utf-8">
      function onLoad()

      { document.addEventListener("deviceready",onDeviceReady,false); }

      function onDeviceReady()

      { pictureSource=navigator.camera.PictureSourceType; destinationType=navigator.camera.DestinationType; }

      function uploadFile(mediaFile,method) {
      var ft = new FileTransfer(),
      path = mediaFile,
      name = "video.3gp";
      var options = new FileUploadOptions();
      options.chunkedMode = false;
      options.fileKey = "file";
      options.fileName = name;
      options.mimeType = "video/mpeg";
      ft.upload(path,
      "http://www.myserver.com/upload.php",
      function(r)

      { alert('Success ' + r.response); }

      ,
      function(error)

      { alert('Error ' + path + ': ' + error.code); }

      ,
      options);
      }
      function onPhotoURISuccess(imageURI)

      { uploadFile(imageURI,"library"); }

      function getVideo(source, type) {
      navigator.camera.getPicture(onPhotoURISuccess, onFail,

      { quality: 50, destinationType: destinationType.FILE_URI, sourceType: source, mediaType: type}

      );
      }
      function onFail(message)

      { alert('Error'); }

      </script>
      </head>
      <body onload="onLoad()">
      <button class="btn"
      onclick="getVideo(pictureSource.PHOTOLIBRARY,Camera.MediaType.VIDEO);">Get
      Video</button>
      </body>
      </html>

      Attachments

        Activity

          People

            macdonst Simon MacDonald
            emibap Emiliano Angelini
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: