Android Open Source - sudoku Music






From Project

Back to project page sudoku.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project sudoku listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hao.apps.sudoku;
//from ww  w .j  a v  a 2s .c  o  m
import android.content.Context;
import android.media.MediaPlayer;

public class Music {

  private static MediaPlayer mp = null;

  public static void startMusic(Context context) {
    if (Settings.getMusicState(context)) {
      stop(context);
      int r = (int) (Math.random() * 10);
      int choise = 0;
      if (r > 5){
        choise = 1;
      }else {
        choise = 2;
      }
      
      switch (choise) {
      case 1:
        mp = MediaPlayer.create(context, R.raw.a);
        break;
      case 2:
        mp = MediaPlayer.create(context, R.raw.b);
        break;
      default:
        break;
      }
      mp.setLooping(true);
      mp.start();
    }

  }

  public static void stop(Context context) {
    if (Settings.getMusicState(context)) {
      if (mp != null) {
        mp.release();
        mp = null;
      }
    }

  }

}




Java Source Code List

com.hao.apps.sudoku.About.java
com.hao.apps.sudoku.Game.java
com.hao.apps.sudoku.KeyPad.java
com.hao.apps.sudoku.Music.java
com.hao.apps.sudoku.PuzzleView.java
com.hao.apps.sudoku.Settings.java
com.hao.apps.sudoku.Sudoku.java
com.hao.apps.sudoku.algorithm.SudokuAlgorithm.java
com.hao.apps.sudoku.algorithm.SudokuUtils.java