2

I have some locally stored mp3 files which are already encrypted. I want to play (stream) the files while they're decrypting rather than waiting for them to finish decrypting, then stream. However, when I use the FileDescriptor and attempt to stream the content, I get an IOException:

Unable to to create media player
setDataSourceFD failed.: status=0x80000000
java.io.IOException: setDataSourceFD failed.: status=0x80000000
    at android.media.MediaPlayer.setDataSource(Native Method)
    at android.media.MediaPlayer.setDataSource(MediaPlayer.java:976)

How can I resolve this issue and stream content as it decrypts?

P.S. I'm able to play already the already decrypted files, but I want them to play during the process of decryption to reduce the time taken before audio can play

Patrick W
  • 1,485
  • 4
  • 19
  • 27
  • Where are you getting this `FileDescriptor` from, if you do not have a decrypted file? – CommonsWare Aug 15 '14 at 12:56
  • Possibly related: [Exception when calling setDataSource(FileDescriptor) method (failed.: status=0x80000000)](http://stackoverflow.com/questions/4795104/exception-when-calling-setdatasourcefiledescriptor-method-failed-status-0x8) – Duncan Jones Aug 15 '14 at 12:57
  • @CommonsWare I'm using Apache Shiro to decrypt. Since the OutputStream in use is an instance of FileOutputStream, I'm retrieving the FileDescriptor for this stream and trying to pass it to the MediaPlayer::setDataSource method. – Patrick W Aug 15 '14 at 13:29
  • @Duncan the related question you pointed out has a self-accepted answer which does not solve the problem. Like I pointed out, the file is valid since it plays after it's decrypted. The functionality I need to work with is one similar to streaming media from remote locations using a protocol like http, which does not wait for complete download of the file – Patrick W Aug 15 '14 at 13:35
  • I would expect that the `FileDescriptor` from `FileOutputStream` is for writing, not reading. – CommonsWare Aug 15 '14 at 13:35
  • @patwanjau I was thinking [this](http://stackoverflow.com/a/11351599/474189) was the more interesting answer there. – Duncan Jones Aug 15 '14 at 13:36
  • @CommonsWare Does that imply that I cannot use a FileDescriptor in this case since the FileInputStream contains encrypted Data? – Patrick W Aug 15 '14 at 13:48
  • @Duncan that may seem so, but the same media content can be played once completely decrypted or if I use it's remote handle, that is using it's http/https protocol. Does that mean the header (if at the end of the file) is still retrieved before the content? – Patrick W Aug 15 '14 at 13:51
  • I would not expect either of those `FileDescriptor` objects to help you. I have tried implementing this using a `ParcelFileDescriptor` pipe from a `ContentProvider`, but the resulting stream is not seekable, which makes `MediaPlayer` unhappy. AFAIK, using HTTP is the only option, and that opens up other security challenges (e.g., how to prevent other apps from using that server). – CommonsWare Aug 15 '14 at 13:59

0 Answers0