我正在创建一个包含音频网址列表的应用。 我的代码在我的模拟器中工作( Android 6.0 ),其规格是
但是我的物理设备Redmi note3( Android 6.0.1 )
也适用于三星s7562 Android版 4.0.4 我试图搜索,但我没有找到任何解决方案。
请看代码......
holder.mp_play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
players[position] = new MediaPlayer();
Log.e(MyUtils.DEBUG, "Playing Position:" + playingPosition);
holder.progressBar.setVisibility(View.VISIBLE);
holder.mp_play.setVisibility(View.GONE);
holder.mp_pause.setVisibility(View.GONE);
holder.mp_stop.setVisibility(View.GONE);
if (playingPosition != -1) {
if (players[playingPosition].isPlaying()) {
players[playingPosition].stop();
players[playingPosition].release();
notifyDataSetChanged();
}
}
playingPosition = position;
lastPlayingPosition = position;
try {
players[position].setAudioStreamType(AudioManager.STREAM_MUSIC);
players[position].setDataSource(classArrayList.get(position).getSongUrl());
players[position].prepareAsync();
players[position].setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
Log.e(MyUtils.DEBUG,"Prepared");
holder.progressBar.setVisibility(View.GONE);
players[position].start();
}
});
players[position].setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mediaPlayer, int progress) {
Log.e(MyUtils.DEBUG, "Progress: " + progress);
if (progress > 50) {
holder.progressBar.setVisibility(View.GONE);
holder.mp_play.setVisibility(View.GONE);
holder.mp_pause.setVisibility(View.GONE);
holder.mp_stop.setVisibility(View.VISIBLE);
players[position].setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
isPlaying=false;
holder.progressBar.setVisibility(View.GONE);
holder.mp_play.setVisibility(View.VISIBLE);
holder.mp_pause.setVisibility(View.GONE);
holder.mp_stop.setVisibility(View.GONE);
}
});
isPlaying=true;
// notifyDataSetChanged();
Log.e(MyUtils.DEBUG, "BUFFER END");
} else {
holder.progressBar.setVisibility(View.VISIBLE);
holder.mp_play.setVisibility(View.GONE);
holder.mp_pause.setVisibility(View.GONE);
Log.e(MyUtils.DEBUG, "BUFFER START");
holder.mp_stop.setVisibility(View.GONE);
}
}
});
} catch (IOException e) {
e.printStackTrace();
Log.e(MyUtils.DEBUG,"Error:"+e.getMessage());
}
}
});
这是我的日志...
05-04 21:41:38.828 11306-11306/com.progontech.bithirisathi E/ExtMediaPlayer-JNI: env->IsInstanceOf fails
05-04 21:41:38.828 11306-11306/com.progontech.bithirisathi E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
05-04 21:41:38.828 11306-11306/com.progontech.bithirisathi E/ExtMediaPlayer-JNI: env->IsInstanceOf fails
05-04 21:41:38.828 11306-11306/com.progontech.bithirisathi E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0
05-04 21:41:38.829 11306-11306/com.progontech.bithirisathi E/DEBUG: Playing Position:0
05-04 21:41:38.837 11306-11322/com.progontech.bithirisathi D/MediaHTTPConnection: filterOutInternalHeaders: key=User-Agent, val= stagefright/1.2 (Linux;Android 6.0.1)
05-04 21:41:38.838 11306-11321/com.progontech.bithirisathi D/MediaHTTPConnection: proxy null port 0
05-04 21:41:39.943 11306-11306/com.progontech.bithirisathi E/DEBUG: Progress: 100
05-04 21:41:39.945 11306-11306/com.progontech.bithirisathi E/DEBUG: BUFFER END
05-04 21:41:39.946 11306-11306/com.progontech.bithirisathi D/MediaPlayer: setSubtitleAnchor in MediaPlayer
05-04 21:41:39.950 11306-11306/com.progontech.bithirisathi E/DEBUG: Prepared
05-04 21:41:40.219 11306-11306/com.progontech.bithirisathi E/DEBUG: Progress: 100
05-04 21:41:40.219 11306-11306/com.progontech.bithirisathi E/DEBUG: BUFFER END
05-04 21:41:40.239 11306-11358/com.progontech.bithirisathi E/MediaPlayer: error (1, -2147479551)
05-04 21:41:40.239 11306-11306/com.progontech.bithirisathi E/MediaPlayer: Error (1,-2147479551)
05-04 21:41:40.240 11306-11319/com.progontech.bithirisathi E/MediaPlayer: error (1, -38)
05-04 21:41:40.251 11306-11306/com.progontech.bithirisathi E/MediaPlayer: Error (1,-38)
提前致谢。