Reputation: 3921
I need to streaming media and video from samba server to android, and I use JCIFS to get inputstream from samba file.
But in MediaPlayer only can use fileinputstream.getFD() to play media.
mp = new MediaPlayer();
FileInputStream fis = new FileInputStream(convertedFile);
mp.setDataSource(fis.getFD());
Toast.makeText(this, "Success, Path has been set", Toast.LENGTH_SHORT).show();
mp.prepare();
mp.start();
I can't getFD() from inputstream so that I need to convert inputstream to fileinputstream...
Please give me a suggest, or there hava others solution to streaming media from samba server ?
This is my SmbFileInputStream, but it's not equals than fileinputstream
SmbFileInputStream f = new SmbFileInputStream(new SmbFile(filePath,auth));
Thanks a lot.
Upvotes: 0
Views: 1137
Reputation: 1007099
You can create a ParcelFileDescriptor
pipe using createPipe()
. You would copy bytes from your FileInputStream
into an OutputStream
on your end of the pipe, and give the FileDescriptor
from getFileDescriptor()
to MediaPlayer
. Whether this will work or not with your desired stream is a completely different matter, but it's the only way I know of to get a FileDescriptor
that represents arbitrary content.
Here is a sample application demonstrating this, in the context of implementing openFile()
on a ContentProvider
.
Upvotes: 1