Mediaplayer loading audio Streaming
Bonjour a tous,
Citation:
j'ai un problème avec l'audio streaming,lorsque je click sur play j'attent presque 10s a fin que le streaming marche,je vous ajouter un animation loading entre play et pause,le temps quelle faille pour que le audio streaming marche,j'ai pas des connaissance au niveau d'animation android,si vous avez une idée,merci d'avance, voila ma méthode:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| private void play(String path){
if(!prepared)
prepare();
mediaPlayer.start();
btplayer.setBackgroundResource(R.drawable.stop);
onPlay=true;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| private void prepare() {
// TODO Auto-generated method stub
try {
mediaPlayer.setDataSource(lien);
prepared=true;
} catch (Exception e) {
// TODO Auto-generated catch block
//showDialog("Sorry :the link is incorect or failed to locate");
//showDialog("Nous ne pouvons pas nous connecter à la radio pour le moment. Vérifiez votre connection Internet et assurer-vous d'être connecté à un réseau 3G ou Wifi.");
e.printStackTrace();
}
try {
Log.e("Avant ------------<<<<","OnPrepar");
btplayer.setBackgroundResource(R.drawable.loading);
mediaPlayer.prepare();
Log.e("Apres ------------<<<<","OnPrepar");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
Code:
1 2 3 4 5
| private void pause(){
mediaPlayer.pause();
btplayer.setBackgroundResource(R.drawable.play);
onPlay=false;
} |