2

I had 4mb, around 4min long ogg file to play as background music.

When i launch it , the music stops at 20sec I cut it down to 50 sec and it occasionally stops at 35-40 sec play time.

generic = MediaPlayer.create(this, R.raw.rep2);
    generic.setLooping(true);
    generic.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.start();
        }
    });

    generic.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            mp.release();

        }
    });

As a solution i may consider cutting 4min track into several 50 sec tracks and play them sequentially.

What is the maximum track length, or music file size standard media player can play in android without stops?

ERJAN
  • 23,696
  • 23
  • 72
  • 146
  • Interesting question @ERJAN, did you resolve it? I've a similar issue. I finally got my (approx. 2.5 minute long) ogg file looping perfectly, however when the app initially starts, the file simply refuses to play from the very beginning. It starts at around half a second into it (basically, skipping the first half second). But, when it loops, it then *does* re-start right from the beginning. If I cut the length down (don't recall the exact length, but it's around 1.5 minutes), it starts initially right at the beginning as I would expect. I'd be interested to hear how you got around this. – Zippy Jan 17 '17 at 21:29

0 Answers0