简体   繁体   English

Android上的音频流

[英]Audio Streaming on Android

I'm attempting to stream from a URL using Android's built in MediaPlayer class. 我正在尝试使用Android的内置MediaPlayer类从URL流式传输。 However, I also need to send a special header along with the URL. 但是,我还需要发送一个特殊的标头以及URL。 Is this possible without having to rewrite the whole steaming process? 是否可以不必重写整个蒸煮过程?

If it's not possible to send a header, I would need to stream the file manually. 如果无法发送标头,则需要手动流式传输文件。 However, it appears that the MediaPlayer class locks the file you are writing to when it begins reading the file. 但是,似乎MediaPlayer类在开始读取文件时会锁定您正在写入的文件。 This means you cant just simply continue writing to the file while reading from it. 这意味着您不能在读取文件时继续简单地继续写入文件。 I've seen the 'double buffer' method however that results in choppy playback. 我见过“双缓冲区”方法,但是会导致断断续续的播放。 Any suggestions? 有什么建议么?

I asked a question recently about alternatives to the double buffer method you mentioned: 我最近问了一个有关您提到的双缓冲方法的替代方法的问题:
is-there-a-better-way-to-save-streamed-files-with-mediaplayer 有一种更好的方式来保存媒体播放器的流文件

I guess you could act as a proxy in a thread, handle your header and forward the rest to the media player? 我猜您可以充当线程的代理,处理标头并将其余的转发给媒体播放器? Or if you control the server pass the extra data in a different request... 或者,如果您控制服务器,则在其他请求中传递额外的数据...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM