bemeyer
bemeyer

Reputation: 6221

Mediaplayer Stops playing

In our Gamefield class do we want to start a simple Mediaplayer with a Backgroundmusik like this

public GameField(Context context, int width, int height) {
    super(context);
    getHolder().addCallback(this);
    // get an instance of the gameLoop
    setFocusable(true); // events happen on this view

    //Starting soundloop
    MediaPlayer play = MediaPlayer.create(this.getContext(), R.raw.coryphee_coryphee);
    play.setLooping(true);
    play.start(); ......

This actually stops after some time playing the musik. In our Mainacivity do we start a Mediaplayer like this and it does not stop playing.

Why does it stop and how can if fix it? We fixed it with running it in a Thread but i think it should work like this. Every tutorial i could find do it like this so i am a bit helpless

Best Regards and thanks alot.

Upvotes: 0

Views: 4715

Answers (1)

Omarj
Omarj

Reputation: 1159

Look at this one it is the same case for you.

Link

but i think it is something else at your case.

Upvotes: 3

Related Questions