We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is my plugin https://www.npmjs.com/package/cordova-plugin-readmedia-codeplay I have done this already in my cordova plugin, please check the code below and please implement these fractures on this plugin
package cordova.plugin.readmedia.codeplay; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CallbackContext; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CallbackContext; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /** * This class echoes a string called from JavaScript. */ public class readmedia extends CordovaPlugin { @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("getAudioFiles")) { this.getFiles(callbackContext,"audio"); return true; } if (action.equals("getVideoFiles")) { this.getFiles(callbackContext,"video"); return true; } if (action.equals("getImageFiles")) { this.getFiles(callbackContext,"image"); return true; } return false; } private void getFiles(CallbackContext callbackContext,String fileType) { ContentResolver contentResolver = this.cordova.getActivity().getContentResolver(); Uri uri=null; String[] projection=null; if (fileType.equals("audio")) { uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; projection = new String[]{ MediaStore.Audio.Media.DURATION, MediaStore.Audio.Media._ID, MediaStore.Audio.Media.DISPLAY_NAME, MediaStore.Audio.Media.DATA }; } else if (fileType.equals("video")) { uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; projection = new String[]{ MediaStore.Video.Media.DURATION, MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.DATA }; } else if(fileType.equals("image")) { uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; projection = new String[]{ MediaStore.Images.Media.DURATION, MediaStore.Images.Media._ID, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATA }; } /* // Modify the selection clause to filter by directory String selection = MediaStore.Audio.Media.DATA + " like ?"; String[] selectionArgs = new String[]{"%/Music/%"}; // Adjust this path to the desired directory */ Cursor cursor = contentResolver.query(uri, projection, null, null, null); JSONArray audioFiles = new JSONArray(); if (cursor != null) { while (cursor.moveToNext()) { JSONObject audioFile = new JSONObject(); try { audioFile.put("id", cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media._ID))); audioFile.put("name", cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME))); audioFile.put("path", cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA))); audioFiles.put(audioFile); } catch (JSONException e) { e.printStackTrace(); } } cursor.close(); } callbackContext.success(audioFiles); } } /* <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" /> <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" /> cordova.plugins.readmedia.getAudioFiles(function(a){ debugger; },function(a){ debugger; }) cordova.plugins.readmedia.getVideoFiles(function(a){ debugger; },function(a){ debugger; }) cordova.plugins.readmedia.getImageFiles(function(a){ debugger; },function(a){ debugger; }) var permissions = cordova.plugins.permissions; permissions.requestPermission(permissions.READ_MEDIA_AUDIO, function(status) { if (status.hasPermission) { console.log('Permission granted'); // Permission granted, you can now proceed with operations requiring this permission } else { console.log('Permission denied'); // Handle the case where permission is denied } }, function(error) { console.error('Error requesting permission:', error); }); var permissions = cordova.plugins.permissions; permissions.requestPermission(permissions.READ_MEDIA_VIDEO, function(status) { if (status.hasPermission) { console.log('Permission granted'); // Permission granted, you can now proceed with operations requiring this permission } else { console.log('Permission denied'); // Handle the case where permission is denied } }, function(error) { console.error('Error requesting permission:', error); }); var permissions = cordova.plugins.permissions; permissions.requestPermission(permissions.READ_MEDIA_IMAGES, function(status) { if (status.hasPermission) { console.log('Permission granted'); // Permission granted, you can now proceed with operations requiring this permission } else { console.log('Permission denied'); // Handle the case where permission is denied } }, function(error) { console.error('Error requesting permission:', error); }); */
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This is my plugin https://www.npmjs.com/package/cordova-plugin-readmedia-codeplay
I have done this already in my cordova plugin, please check the code below and please implement these fractures on this plugin
The text was updated successfully, but these errors were encountered: