You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
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.
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.
Activity
spark85 commentedon Jan 20, 2015
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.
ojw28 commentedon Jan 20, 2015
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.
Nezz commentedon Jan 20, 2015
Me too. I would have done it already, but I was too lazy to set up the environment to build it :)
FrameworkSampleSource with FileDescriptor google#246
FrameworkSampleSource with FileDescriptor google#246
Nezz commentedon Jan 21, 2015
Works flawlessly for me.
ojw28 commentedon Jan 21, 2015
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.