Skip to content

FrameworkSampleSource with FileDescriptor #246

Closed

Description

@Nezz

Currently FrameworkSampleSource is designed to work with URIs. This makes it rather inconvenient to play media from other sources, like the APK (Assets for example). It would be a one line change to make it work with with a FileDescriptor, since MediaExtractor has a setDataSource overload for that.

My questions are:
Is there a way to play files from the Assets folder?
Are there any plans to add support for it?
Would it make sense to add a new SampleSource that is the same as FrameworkSampleSource just with that single line changed?

Activity

  1. spark85 commented on Jan 20, 2015

    @spark85

    I changed the implementation with a custom SampleSource to use a FileDescriptor. I obtained the FileDescriptor by creating an InputStream wrapped around a File object with the correct file name. That fixed the issue with the MediaExtractor; and when I examined the MediaFormat it had all of the correct attributes. (* I will post them by tomorrow morning).

    However, that still didn't solve the problem. The player crashes when it tries to play the file, with a Signal 6 error; and FILE_DATA_SOURCE_END.

    I could use the asset folder; however, for security reasons we prefer to keep the media in internal storage.

  2. ojw28 commented on Jan 20, 2015

    @ojw28
    Contributor

    We can add an additional FrameworkSampleSource constructor that takes a FileDescriptor, if that helps. I'd like to understand the "still doesn't solve the problem" part though.

  3. Nezz commented on Jan 20, 2015

    @Nezz
    ContributorAuthor

    Me too. I would have done it already, but I was too lazy to set up the environment to build it :)

  4. Nezz commented on Jan 21, 2015

    @Nezz
    ContributorAuthor

    Works flawlessly for me.

  5. ojw28 commented on Jan 21, 2015

    @ojw28
    Contributor

    Closing this as the change is merged. It's likely the "still doesn't solve the problem" issue is something else. Feel free to open a separate issue to track that, if needed.

  6. locked and limited conversation to collaborators on Jun 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions