StansAssets / com.stansassets.android-native

Android Native Plugin Wiki
https://api.stansassets.com/android-native/
9 stars 1 forks source link

Feature request - Access to user audio files #27

Open dementcore opened 4 years ago

dementcore commented 4 years ago

It will be great if the plugin provides an API to enumerate and get all user music in the device.

stan-osipov commented 4 years ago

I will definitely consider it. But can you be a bit more specific? What I mean is, can you list the Android Native API you would like to get?

My guess is you probably want son subset of Medial Player API? https://developer.android.com/guide/topics/media/mediaplayer

Looking forward to your replay :)

dementcore commented 4 years ago

Hi Stan, Sorry for the misunderstanding. The API I refer is this: https://developer.android.com/reference/android/provider/MediaStore.Audio https://developer.android.com/reference/android/content/ContentResolver

It will be a great to make querys to the ContentResolver with MediaStore columns to get user's multimedia files and a Unity API to get AudioClip.

For example a game where a user can play music that is in the device.

I let you this code that i have make for more clarity.

        Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
        String[] projection = {
                MediaStore.Audio.AudioColumns.DATA,
                MediaStore.Audio.AudioColumns.TITLE,
                MediaStore.Audio.Media.DURATION,
                MediaStore.MediaColumns._ID
        };

        Context context = UnityPlayer.currentActivity;

        Cursor c = context.getContentResolver().query(uri, projection,null,null,null);

Thanks!