如何从Firebase播放mp3?

时间:2019-01-08 22:09:44

标签: java android firebase android-mediaplayer firebase-storage

我正在按照以下方式从Firebase Storage下载文件sound1.mp3,但我不知道如何播放该文件,该怎么办?     FirebaseStorage storage = FirebaseStorage.getInstance();

StorageReference mp3_referansim= storage.getReference();
StorageReference MP3_İNDİR=mp3_referansim.child("ses1.mp3");

final File localFile= File.createTempFile("ses1","mp3");

public Okuma() throws IOException {
}



int yazı_boyutu,font,renk,satir_bosluk,oynat_durdur=0;

Bitmap bmp;

@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.okuma_activity);



    StorageReference MP3_İNDİR=mp3_referansim.child("ses1.mp3");
    MP3_İNDİR.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
        @Override
        public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {

            Toast.makeText(getApplicationContext(),"DOWNLOADED",
                    Toast.LENGTH_SHORT).show();


        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            Toast.makeText(getApplicationContext(),"FAILED",
                    Toast.LENGTH_SHORT).show();            }
    });

0 个答案:

没有答案