1

I am trying to play media from LocalSocket using MediaPlayer. The stream is of type MPEG-TS, which is availale in a LocalSocket input stream

Following code tries to setDataSource to the FileDescriptor of LocalSocket, but failes.

LocalSocket wsIns = fileThread.getReadSocket();
p = new MediaPlayer();
p.setDisplay(holder);
FileDescriptor fd = wsIns.getFileDescriptor();
Log.e("TS","is valid ? "+fd.valid());
p.setDataSource(fd ,0, fileThread.getLength());

setDataSource fails with following exception.

10-13 17:21:31.510: W/System.err(6472): java.io.IOException: setDataSourceFD failed.: status=0x80000000
10-13 17:21:31.510: W/System.err(6472):     at android.media.MediaPlayer.setDataSource(Native Method)
10-13 17:21:31.510: W/System.err(6472):     at com.example.test.TSRenderActivity.surfaceCreated(TSRenderActivity.java:94)

The debug logs suggest that the error is primarily due to this, where fstat on the LocalSocket's file descriptor returns size of the file as 0.

But if I try wsIns.getInputStream().available() this api gives non zero number of bytes available.

Note : The same error on using p.setDataSource(fp);

nmxprime
  • 1,506
  • 3
  • 25
  • 52

0 Answers0