Go to file
2017-08-24 17:22:24 +08:00
src/android Add files via upload 2017-08-16 15:30:01 +08:00
www Add files via upload 2017-08-16 15:30:15 +08:00
package.json Add files via upload 2017-08-17 16:34:52 +08:00
plugin.xml Add files via upload 2017-08-17 16:34:52 +08:00
readme Create readme 2017-08-24 17:22:24 +08:00
README.md Update README.md 2017-08-18 10:43:34 +08:00

cordova-plugin-mediaPicker

android mediaPicker support selection of multiple image and video

How do I use?

use npm:

  cordova plugin add cordova-plugin-mediapicker-dmcbig

Example

html code:

<body>
    <div>
        <img name="imgView"  width="100px"  height="100px" >
        <img name="imgView"  width="100px"  height="100px" >
    </div>
    <button id="openBtn">open</button>
    <button id="uploadBtn">upload</button>

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
</body>

index.js code:

var imgs=document.getElementsByName('imgView');
var args={'showThumbnail':true,
           'selectMode':101,//101=PICKER_IMAGE_VIDEO , 100=PICKER_IMAGE
           'maxSelectCount':12, //default 40 (Optional)
           'maxSelectSize':188743680,//188743680=180M (Optional)
          };

document.getElementById('openBtn').onclick=function(){

    MediaPicker.getMedias(args,function(dataArray){
        //dataArray [{mediaType: "image",rotate: 90, path:'/storage/emulated/0/DCIM/Camera/20170808_145202.jpg' thumbnailBase64: '9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEB'}]
        for(var i=0; i<dataArray.length; i++){
            imgs[i].src= 'data:image/jpeg;base64,'+dataArray[i].thumbnailBase64;
            imgs[i].setAttribute('style', 'transform:rotate(' + dataArray[i].rotate + 'deg)');
        }
    },function(err){
        console.log(err);
    })
 };

 document.getElementById('uploadBtn').onclick=function() {
    //please:  cordova plugin add cordova-plugin-file-transfer
    //see:  https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/index.html
 };

Screenshots