MediaPlayer的()音频口吃(机器人) [英] MediaPlayer() audio stuttering(android)

查看:348
本文介绍了MediaPlayer的()音频口吃(机器人)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用功能的MediaPlayer流从远程服务器实时音频流,在我的Andr​​oid应用程序。但声音不连贯和口吃。问题不在于我的互联网作为饲料发挥完美,当我玩电脑。可能是什么问题*注:流是活的。
这是code我使用的是:

  MediaPlayer的熔点为新的MediaPlayer();
    尝试{
    mp.setDataSource(HTTP:// radiotool:80 /饲料342.mp3); //硬codeD用于测试目的
    MP prepare()。
    mp.start();
    }
    赶上(例外五)
    {Log.d(错误上来的人,请检查网络连接和东西..);


解决方案

您链接到没有在流的开始发送大量的数据缓冲流。通常这是没有问题的,作为客户端负责确定重放的速率,看所述数据传输速率,并且相应地管理客户端缓冲。这就是为什么当我给你一个链接去尝试,它使用一个大的缓冲区,这不是玩的一个问题。

基本上,音频丢失是由于不断的缓冲区欠载。为了解决这个问题,就需要增加缓冲区的大小。看来,现在这是不可能的,但另一种方法可能是自行管理HTTP客户端和代理数据,以在MediaPlayer 的。这种联系是很老...希望有人想出如何做这另一种方式至今。我不是一个Android开发者,所以我不能告诉你是肯定的。

我会做的首先是调用 MP。prepareAsync(),并等待2秒的MediaPlayer告诉你之后,它已准备好开始。我有一种预感,数据将继续在后台缓冲,直到你实际调用。开始()

I am using the MediaPlayer function to stream a live audio stream from a remote server, in my android app. But the audio is choppy and stuttering. The problem is not my internet as the feed plays perfectly when I play it on the computer. What could be the problem?*Note: the streams are live. This is the code I'm using:

MediaPlayer mp = new MediaPlayer();
    try{
    mp.setDataSource("http://radiotool:80/feed 342.mp3");//hardcoded for testing purposes
    mp.prepare();
    mp.start();
    }
    catch(Exception e)
    {Log.d("Error came up man",", check the internet connection and stuff..");

解决方案

The stream you are linking to is not sending a large buffer of data at the beginning of the stream. Normally this is not a problem, as the client is responsible for determining the rate of playback, watching the data transfer rate, and managing a client-side buffer accordingly. That is why when I gave you a link to try that does use a large buffer, this wasn't a problem to play.

Basically, the audio dropouts are due to constant buffer underruns. To fix this, you need to increase the buffer size. It seems this isn't possible right now, but another method may be to manage the HTTP client yourself and proxy the data to the MediaPlayer. That link is quite old... hopefully someone has figured out how to do this another way since then. I am not an Android developer, so I cannot tell you for sure.

What I would do first is call mp.prepareAsync(), and wait 2 seconds after the MediaPlayer tells you that it is ready to start. I have a hunch that data will continue to buffer in the background until you actually call .start().

这篇关于MediaPlayer的()音频口吃(机器人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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