Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.media.MediaPlayer;

public class Main {
    private static MediaPlayer music;
    private static boolean musicSt = true;
    private static Context context;

    public static void playMusic(int resId) {
        if (musicSt == false)
            return;

        music = MediaPlayer.create(context, resId);
        music.setLooping(true);
        startMusic();
    }

    public static void startMusic() {
        if (musicSt)
            music.start();
    }
}