Skip to content
New issue

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

[Enhancement]: Remove a lot of providers from the Manifest. #123

Open
isabsent opened this issue Jan 24, 2020 · 5 comments
Open

[Enhancement]: Remove a lot of providers from the Manifest. #123

isabsent opened this issue Jan 24, 2020 · 5 comments

Comments

@isabsent
Copy link

You have a lot of 'providertags inManifest` as:

    <provider
        android:name="dev.dworks.apps.anexplorer.provider.NonMediaDocumentsProvider"
        android:authorities="${applicationId}.nonmedia.documents"
        android:exported="true"
        android:grantUriPermissions="true"
        android:permission="android.permission.MANAGE_DOCUMENT">
        <intent-filter>
            <action android:name="dev.dworks.apps.anexplorer.action.DOCUMENTS_PROVIDER" />
        </intent-filter>
    </provider>

with the only difference in android:authorities="${applicationId}.nonmedia.documents". I suppose you can combine most of them under one provider tag with

    <meta-data
         android:name="android.support.FILE_PROVIDER_PATHS"
         android:resource="@xml/file_provider_paths"/>

specifying all needed path in file_provider_paths.

@shubham696
Copy link

@isabsent hello, sorry for commenting here.
I went through your answer at 'google/ExoPlayer#4212 (comment)' for feeding byte array to Exoplayer.
But as a new to android, I'm unable to understand and implement it. Can you help me with it?

@isabsent
Copy link
Author

isabsent commented Feb 9, 2020

Hi!
The answer you link is concerned with how to use ExoPlayer when you haven't a source like byte[], File or ByteBuffer where random access to the source is available. You have an InputStream (not FileInputStream or ByteArrayInputStream) and want to play media from it. If you have a byte[] as a source, the problem is disappear. What is a task you a trying to solve?

@shubham696
Copy link

shubham696 commented Feb 9, 2020 via email

@isabsent
Copy link
Author

isabsent commented Feb 9, 2020

If you already have your data as a byte[] to the moment you are going to send it to ExoPlayer, you can envelop your byte[] in the ByteArrayDataSource and create a MediaSource from it:

public MediaSource createMediaSourceFromByteArray(byte[] bytes) {
    ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(bytes);
    DataSource.Factory factory = new DataSource.Factory() {

        @Override
        public DataSource createDataSource() {
            return byteArrayDataSource;
        }
    };
    MediaSource mediaSource = new ExtractorMediaSource.Factory(factory)
            .setExtractorsFactory(new DefaultExtractorsFactory())
            .createMediaSource(Uri.EMPTY);
    return Objects.requireNonNull(mediaSource, "MediaSource cannot be null");
}

Then, you can set above MediaSource to ExopLayer:

MediaSource byteArrayMediaSource = createMediaSourceFromByteArray(bytes);
exoPlayer.prepare(byteArrayMediaSource);

@shubham696
Copy link

shubham696 commented Feb 9, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants