修改的FileInputStream的媒体播放器的setDataSource媒体播放器、FileInputStream、setDataSource

2023-09-13 02:05:30 作者:深夜鱼棠

我想修改(扩展)的的FileInputStream 类,这样我可以打开加密的文件,并使用流MediaPlayer的的setDataSource(的FileDescriptor)。问题是我不知道哪一种方法应该重写做流中解密。我试图覆盖所有的阅读()的方法,但是媒体播放器似乎没有使用它们。

I'm trying to modify (extend) the FileInputStream class so that I can open an encrypted file and use the stream for MediaPlayer's setDataSource(FileDescriptor). Problem is I don't know which method should be overridden to do the decryption inside the stream. I tried overriding all the read() methods, but the mediaPlayer doesn't seem to use them.

有什么建议?

推荐答案

我不认为MediaPlayer的接受任何形式的InputStream的。你不能修改已在使用的MediaPlayer从文件中读取数据。

I don't think that MediaPlayer accepts any kind of InputStream. You can't modify data read from file that are used in MediaPlayer.

MediaPlayer的接受的FileDescriptor(本机code作为从实际文件读取,没有回调到Java)。而MediaPlayer的acceps HTTP URL。

MediaPlayer accepts FileDescriptor (processed in native code as reads from real file, no call back to Java). And MediaPlayer acceps http URL.

如果您确实需要修改传递数据,考虑使用local HTTP服务器并用的setDataSource URI。

If you really need modify passed data, consider using local http server and setDataSource with URI.