简体   繁体   English

如何在 android 应用程序中更快地流式传输歌曲(mp3 文件)

[英]How to stream songs (mp3 files) faster in android app

I am using MediaPlayer class to stream MP3 files from server.我正在使用MediaPlayer类从服务器流式传输 MP3 文件。 MediPlayer.setDataSource() , MediaPlayer.prepare() and MediaPlayer.start() are the three methods which i am using to stream music in my app. MediPlayer.setDataSource()MediaPlayer.prepare()MediaPlayer.start()是我用来在我的应用程序中流式传输音乐的三种方法。 The problem is its taking more than 20 to 23 seconds to start playing the song everytime.问题是每次开始播放歌曲都需要超过 20 到 23 秒。 No matter what the mp3 file size on server its taking the same time to start.无论服务器上的 mp3 文件大小如何,它都需要相同的时间来启动。 Do anyone know how to stream mp3 files more faster?有谁知道如何更快地传输 mp3 文件?

You can use Dynamic Adaptive Streaming over HTTP (DASH) or HTTP Live Streaming(HLS) for rich and smoother streaming.您可以使用基于 HTTP 的动态自适应流式传输 (DASH) 或 HTTP 实时流式传输 (HLS) 以获得丰富且更流畅的流式传输。 Google has an advanced library called exoplayer for this purpose.为此,Google 有一个名为exoplayer的高级库。 Try exoplayer for the purpose.为此目的尝试exoplayer

我不知道你所做的代码可能是旧的 http 请求,所以使用 volley 库它很快,很多请求可以一次处理。所以使用 volley 库。或者发布你的代码。

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

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