package com.example.tyre.util;

import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;

import com.example.tyre.R;

/**
 * Created by 杨万里 on 2019/12/24.
 */

public class PlayMusic{
    private static SoundPool mSoundPool;
    private static int soundID;
    private Context context;
    public static void init(Context context) {
        mSoundPool = new SoundPool(3, AudioManager.STREAM_MUSIC, 20);
        soundID = mSoundPool.load(context, R.raw.scan, 1);
    }
    public static void playSound(Context context) {

        if (mSoundPool == null) {
            mSoundPool = new SoundPool(3, AudioManager.STREAM_MUSIC, 20);
            soundID = mSoundPool.load(context, R.raw.scan, 1);// "/system/media/audio/notifications/Antimony.ogg"
        }
        mSoundPool.play(soundID, 1, 1, 0, 0, 1);
    }
}
