pause function not work mp3 file from firebase

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



pause function not work mp3 file from firebase


play.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View view)
MediaPlayer mediaPlayer=new MediaPlayer();
try
mediaPlayer.setDataSource("https://firebasestorage.googleapis.com/v0/b/photo-on-birthday-cake-cccf5.appspot.com/o/birthday%20(1).mp3?alt=media&token=c1e988b4-f482-4020-8057-53c68195d2fc");
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
@Override
public void onPrepared(MediaPlayer mediaPlayer)
if(flag==0)
mediaPlayer.start();
Toast.makeText(MusicActivity.this, "start", Toast.LENGTH_SHORT).show();
flag=1;
play.setBackgroundResource(R.drawable.ic_pause_circle_outline_black_24dp);
else
mediaPlayer.pause();
Toast.makeText(MusicActivity.this, "Stop", Toast.LENGTH_SHORT).show();
flag=0;


);
mediaPlayer.prepare();


catch (IOException e)
e.printStackTrace();


);



I tried this code but this is not working on pause function while working on play.





Any errors you are getting?
– kiran Biradar
Aug 10 at 13:26





Can you post complete code?
– kiran Biradar
Aug 10 at 13:42





ok sure i upload complete code
– Awais Akhter
Aug 11 at 16:46









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard