我正在创建一个类似youtube的应用程序,仅用于音频,我将每个音频文件分别下载到了android手机,然后一个又一个地播放,但是每次播放一个新音频时,它却无法保持稳定播放演奏的部分有半秒钟的静音间隔。
我尝试使用setNextMediaPlayer方法,但没有成功。
String ip = "192.168.1.110";
int port = 5000;
int id = 1;
int start = 0;
CustomSocket socket = new CustomSocket(ip, port);
socket.SendMessage("play "+Integer.toString(id)+";-1"); // get data on number of parts
int lon = Integer.parseInt(socket.ReceiveMessage_utf8(10));
int numparts = Integer.parseInt(socket.ReceiveMessage_utf8(lon));
int startingpart = start/5000;//what part it starts on
CustomMediaPlayer[] listnew = new CustomMediaPlayer[numparts];//array of media players
CustomMediaPlayer a = GetPart(id, startingpart);//gets first part and plays
try{
a.start();
}catch (NullPointerException e)
{
e.printStackTrace();
}
try {
listnew[startingpart] = a; // add to array
}catch (Exception e){
e.printStackTrace();
}
startingpart++;
for(startingpart=startingpart;startingpart<=numparts;startingpart++) {//for
all the parts
a = GetPart(id, startingpart);//get part
listnew[startingpart] = a;// add to array
try
{
listnew[startingpart-1].setNextMediaPlayer(a);//seting the previous media player to play the new on complition.
}catch (Exception e)
{
e.printStackTrace();
}
}
我原本希望听到这些部分,因为它们是一个文件,但是相反,我听到每个新部分有半秒的音频间隔。我该如何摆脱呢?