diff --git a/readme.md b/readme.md index 3657507..e4b3934 100644 --- a/readme.md +++ b/readme.md @@ -27,52 +27,60 @@ html code: index.js code: +``` +var imgs = document.getElementsByName('imgView'); +var args = { + 'selectMode': 101, //101=picker image and video , 100=image , 102=video + 'maxSelectCount': 40, //default 40 (Optional) + 'maxSelectSize': 188743680, //188743680=180M (Optional) +}; - var imgs=document.getElementsByName('imgView'); - var args={ - 'selectMode':101,//101=picker image and video , 100=image , 102=video - 'maxSelectCount':40, //default 40 (Optional) - 'maxSelectSize':188743680,//188743680=180M (Optional) - }; +document.getElementById('openBtn').onclick = function() { + MediaPicker.getMedias(args, function(medias) { + //medias [{mediaType: "image", path:'/storage/emulated/0/DCIM/Camera/20170808_145202.jpg', size: 21993}] + window.medias = medias; + getThumbnail(medias); + }, function(e) { console.log(e) }) +}; - - document.getElementById('openBtn').onclick=function(){ - MediaPicker.getMedias(args,function(dataArray){ - //dataArray [{mediaType: "image", path:'/storage/emulated/0/DCIM/Camera/20170808_145202.jpg', size: 21993}] - getThumbnail(dataArray); - },err()) - }; - - - function getThumbnail(dataArray){ - for(var i=0; i1048576){ medias[i].quality=50; } else {d ataArray[i].quality=100;} + medias[i].quality = 30; //when the value is 100,return original image + MediaPicker.compressImage(medias[i], function(compressData) { + //user compressData.path upload compress img + console.log(compressData.path); + }, function(e) { console.log(e) }); } +} - function loading(){} - - //ios Video transcoding compression to MP4 (use AVAssetExportPresetMediumQuality) - document.addEventListener("MediaPicker.CompressVideoEvent", function(data) { - alert(data.status+"||"+data.index); - }, false); - +function loading() {} + +//ios Video transcoding compression to MP4 (use AVAssetExportPresetMediumQuality) +document.addEventListener("MediaPicker.CompressVideoEvent", function(data) { + alert(data.status + "||" + data.index); +}, false); +```