Android MediaPlayer with LocalSocket not working <p>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</p> <p>Following code tries to <code>setDataSource</code> to the <code>FileDescriptor</code> of <code>LocalSocket</code>, but failes.</p> <pre><code>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()); </code></pre> <p>setDataSource fails with following exception.</p> <pre><code>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) </code></pre> <p>The debug logs suggest that the error is primarily due to <a href="http://androidxref.com/4.1.2/xref/frameworks/av/media/libmediaplayerservice/MediaPlayerService.cpp#835" rel="nofollow">this</a>, where <code>fstat</code> on the LocalSocket's file descriptor returns size of the file as 0.</p> <p>But if I try <code>wsIns.getInputStream().available()</code> this api gives non zero number of bytes available.</p> <p>Note : The same error on using <code>p.setDataSource(fp);</code></p>