- package com.liu.zhen.utils;
- import android.content.Context;
- import android.content.res.AssetFileDescriptor;
- import android.media.MediaPlayer;
- import android.util.Log;
- /**
- *
- * This class is used for controlling background music
- *
- */
- public class BackgroundMusic {
- private static BackgroundMusic backgroundMusic = null;
- private static final String TAG = "Bg_Music";
- private float mLeftVolume;
- private float mRightVolume;
- private Context mContext;
- private MediaPlayer mBackgroundMediaPlayer;
- private boolean mIsPaused;
- private String mCurrentPath;
- private BackgroundMusic(Context context) {
- this.mContext = context;
- initData();
- }
- public static BackgroundMusic getInstance(Context context) {
- if (backgroundMusic == null) {
- backgroundMusic = new BackgroundMusic(context);
- }
- return backgroundMusic;
- }
- // 初始化一些数据
- private void initData() {
- mLeftVolume = 0.5f;
- mRightVolume = 0.5f;
- mBackgroundMediaPlayer = null;
- mIsPaused = false;
- mCurrentPath =