Quantcast
Channel: Android se detiene al pulsar varias veces un boton - Stack Overflow en español
Viewing all articles
Browse latest Browse all 2

Android se detiene al pulsar varias veces un boton

$
0
0

Estoy desarrollando una app para escuchar radios en streaming pero si pulso 3 veces el botón, esta se detiene.otro problema es que me gustaria que este un segundo en buferring antes que empieze a reproducir para evitar que empiece, se pare y continue.Log Cat:

10-02 21:22:15.160 20358-20358/com.david.animefm2 V/MediaPlayer: message received msg=100, ext1=-38, ext2=010-02 21:22:15.160 20358-20358/com.david.animefm2 V/MediaPlayer: notify(100, -38, 0) callback on disconnected mediaplayer10-02 21:22:15.265 20358-20358/com.david.animefm2 D/ViewRootImpl@e6a08af[MainActivity]: ViewPostImeInputStage processPointer 010-02 21:22:15.323 20358-20358/com.david.animefm2 D/ViewRootImpl@e6a08af[MainActivity]: ViewPostImeInputStage processPointer 110-02 21:22:15.324 20358-20358/com.david.animefm2 V/MediaPlayer: setVideoSurfaceTexture10-02 21:22:15.324 20358-20358/com.david.animefm2 V/MediaPlayer: prepare10-02 21:22:15.324 20358-20358/com.david.animefm2 E/MediaPlayer: prepareAsync called in state 0, mPlayer(0x0)10-02 21:22:15.325 20358-20358/com.david.animefm2 D/AndroidRuntime: Shutting down VM10-02 21:22:15.325 20358-20358/com.david.animefm2 E/AndroidRuntime: FATAL EXCEPTION: main                                                                    Process: com.david.animefm2, PID: 20358                                                                    java.lang.IllegalStateException                                                                        at android.media.MediaPlayer._prepare(Native Method)                                                                        at android.media.MediaPlayer.prepare(MediaPlayer.java:1408)                                                                        at com.david.animefm2.MainActivity$1.onClick(MainActivity.java:72)                                                                        at android.view.View.performClick(View.java:6261)                                                                        at android.widget.TextView.performClick(TextView.java:11180)                                                                        at android.view.View$PerformClick.run(View.java:23748)                                                                        at android.os.Handler.handleCallback(Handler.java:751)                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)                                                                        at android.os.Looper.loop(Looper.java:154)                                                                        at android.app.ActivityThread.main(ActivityThread.java:6776)                                                                        at java.lang.reflect.Method.invoke(Native Method)                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

Este es mi código:

//Boton Reproducir y pausa    Button start = (Button) findViewById(R.id.START);    start.setOnClickListener(new View.OnClickListener() {        @Override        public void onClick(View v) {            if (isPlay ==0) {                try {                    mediaPlayer.setDataSource(url);                    mediaPlayer.prepare();                } catch (IOException e1) {                    e1.printStackTrace();                }                mediaPlayer.start();                //start.setText("PAUSE");                isPlay = 1;            } else if (isPlay == 1) {                mediaPlayer.stop();                //start.setText("START");                isPlay = 2;            }else if (isPlay == 2){                try {                    mediaPlayer.prepare();                } catch (IOException e) {                    e.printStackTrace();                }                mediaPlayer.start();                //start.setText("PAUSE");                isPlay = 1;            }else {                Toast.makeText(getApplicationContext(),"First select a radio station", Toast.LENGTH_SHORT).show();            }        }    });

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>