简体   繁体   中英

GC_CONCURRENT freed 1841K and KILLED my MediaPlayer

SOLVED: needed to declare MP globally.

I have a MediaPlayer playing/looping a sound.

    MediaPlayer mp = MediaPlayer.create(this, R.raw.v);
    mp.setLooping(true);
    mp.start();

and it works fine until I suddenly get

D/dalvikvm(14090): GC_CONCURRENT freed 1841K, 51% free 4335K/8839K, external 10702K/12379K, paused 2ms+4ms

in logcat and MP dies. Any ideas what might have happened and how do I fix that?

Thanks!

Add this line before mp.start()

mp.setLooping(True)

Then set false when you want to stop it looping.

Got it! Just needed to declare MP globally and it works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM