Android的MediaPlayer的 - 下载和流媒体在同一时间重新审视 [英] Android MediaPlayer - Downloading and Streaming at same time revisited

查看:178
本文介绍了Android的MediaPlayer的 - 下载和流媒体在同一时间重新审视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经被问过,但现在随着Android的新版本(最多果冻豆),我想知道是否有一直在下载和在同一时间的流文件的任何进展。从API,它看起来并不像它的本质可能的,因为这些都是可用的setDataSource方法:

This question has been asked before, but now with the newer versions of Android (up to Jelly Bean), I was wondering if there's been any progress on downloading AND streaming a file at the same time. From the API, it doesn't look like it's inherently possible, as these are the available setDataSource methods:

void    setDataSource(String path)
Sets the data source (file-path or http/rtsp URL) to use.
void    setDataSource(Context context, Uri uri, Map<String, String> headers)
Sets the data source as a content Uri.
void    setDataSource(Context context, Uri uri)
Sets the data source as a content Uri.
void    setDataSource(FileDescriptor fd, long offset, long length)
Sets the data source (FileDescriptor) to use.
void    setDataSource(FileDescriptor fd)
Sets the data source (FileDescriptor) to use.

不幸的是它不接受任何形式的一个InputStream。有迹象表明,使用该打开的Andr​​oid应用程序的本地Web服务器老NPR代理code,例如下载内容的远程和输出请求的数据给任何监听套接字,但是那code为2年以上老它仍然作为标准完成这项任务(尽管很多人都报告说,口吃的问题,等等)。

Unfortunately it does not accept an InputStream of any kind. There are examples that use the old NPR proxy code that opens a local web server in the Android App, downloads content remotely, and outputs requested data to any listening sockets, however that code is more than 2 years old and it's still used as the standard for accomplishing this task (even though a lot of people report that there are stuttering issues, etc).

我看着在MediaPlayer类,并希望把它扩大到允许这种行为,但是很多实现通过本地code实现的,并从我读过,不同的设备制造商实现了原生音频功能不同(如果有的话,我不想去触摸它!:))。

I've looked into the MediaPlayer class and wanted to extend it to allow this behaviour however a lot of the implementation is accomplished through native code, and from what I've read, different device manufacturers implement the native audio functionality differently (and if so, I don't want to touch it! :) ).

因此​​,什么是存储,并同时从远程服务器流进来的音频数据(MP3或OGG)的最佳方法,不丢弃该数据? preferably与Android 2.2版本及以上,但输入任何可用的API将AP preciated。

So, what is the best method to store AND concurrently stream incoming audio data (MP3 or OGG) from a remote server, without discarding the data? Preferably with versions of Android 2.2 and above, but input on any available API would be appreciated.

推荐答案

建立一个本地代理是您最好的选择。我没有看过在NPR的例子,但我一直在使用娜迦做过类似。见我的答案<一个href=\"http://stackoverflow.com/questions/12701249/getting-access-to-media-player-cache\">here.

Building a local proxy is your best bet. I haven't looked at the NPR example, but I've done similar using Naga. See my answer here.

这篇关于Android的MediaPlayer的 - 下载和流媒体在同一时间重新审视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆