Java 类android.media.SoundPool 实例源码

项目:homescreenarcade    文件:SoundEngine.java   
public SoundEngine(Context context) {
        this.context = context;

        sounds = new SoundPool(5, AudioManager.STREAM_RING, 0);

        soundsMap = new HashMap<Integer, Integer>();
        soundsMap.put(EATFOOD, sounds.load(context, R.raw.pacmon_waka_waka, 1));
        soundsMap.put(EATGHOST, sounds.load(context, R.raw.pacmon_eating_ghost, 1));
        soundsMap.put(DIE, sounds.load(context, R.raw.pacmon_dies, 1));
        soundsMap.put(READY, sounds.load(context, R.raw.pacmon_opening_song,1));
        soundsMap.put(GAMEOVER, sounds.load(context, R.raw.pacmon_opening_song, 1));
        //soundsMap.put(EATCHERRY, sounds.load(context, R.raw.pacmon_eating_cherry, 1));

        AudioManager mgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

        // the music that is played at the beginning
//      music = MediaPlayer.create(context, R.raw.gameplaymusic);
//      music.setLooping(true);
    }
项目:Synesthesia    文件:GameActivity.java   
protected void loadSounds()
{
    if (null != soundPool) {
        return;
    }

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    AudioAttributes audioAttributes = new AudioAttributes.Builder()
            .setUsage(AudioAttributes.USAGE_GAME)
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
            .build();
    soundPool = new SoundPool.Builder()
            .setMaxStreams(clickers.length + 1)
            .setAudioAttributes(audioAttributes)
            .build();
    for (int i = 0; i < clickers.length; ++i) {
        clickers[i].clickSound = soundPool.load(this, clickers[i].soundId, 1);
    }

    failSound = soundPool.load(this, R.raw.fail, 1);
    successSound = soundPool.load(this, R.raw.success, 1);
}
项目:android-metronome    文件:Metronome.java   
private void initializeSoundPool()
{
    if(sp!=null) {
        sp.release();
        sp=null;
    }
    try {
        sp=new SoundPool.Builder()
            .setMaxStreams(1)
            .build();
        soundId1=sp.load(context.getAssets().openFd("beats/default_bar.wav"), 1);
        soundId2=sp.load(context.getAssets().openFd("beats/default_beat.wav"), 1);
    } catch(IOException ioExc) {
        if(sp!=null) {
            sp.release();
            sp=null;
        }
    }
}
项目:boohee_v5.6    文件:MQSoundPoolManager.java   
public void playSound(@RawRes final int resId) {
    if (this.mSoundSourceMap != null) {
        if (this.mSoundSourceMap.containsKey(Integer.valueOf(resId))) {
            play(((Integer) this.mSoundSourceMap.get(Integer.valueOf(resId))).intValue());
            return;
        }
        this.mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
            public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
                if (status == 0) {
                    MQSoundPoolManager.this.mSoundSourceMap.put(Integer.valueOf(resId),
                            Integer.valueOf(sampleId));
                    MQSoundPoolManager.this.play(sampleId);
                }
            }
        });
        this.mSoundPool.load(this.mContext.getApplicationContext(), resId, 1);
    }
}
项目:appinventor-extensions    文件:Sound.java   
public Sound(ComponentContainer container) {
  super(container.$form());
  thisComponent = this;
  soundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
  soundMap = new HashMap<String, Integer>();
  vibe = (Vibrator) form.getSystemService(Context.VIBRATOR_SERVICE);
  sourcePath = "";
  loadComplete = true;  //nothing to wait for until we attempt to load
  form.registerForOnResume(this);
  form.registerForOnStop(this);
  form.registerForOnDestroy(this);

  // Make volume buttons control media, not ringer.
  form.setVolumeControlStream(AudioManager.STREAM_MUSIC);

  // Default property values
  MinimumInterval(500);

  if (waitForLoadToComplete) {
    new OnLoadHelper().setOnloadCompleteListener(soundPool);
  }
}
项目:ssj    文件:AudioAction.java   
public void registerWithPlayer(SoundPool player)
{
    try
    {
        if(fd != null)
        {
            soundId = player.load(fd, 1);
            fd.close();
        }
        else
        {
            soundId = player.load(res, 1);
        }
    }
    catch (IOException e)
    {
        Log.e("error loading audio files", e);
    }
}
项目:Android-Game-Programming    文件:GameActivity.java   
public void loadSound(){
    soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
    try {
        //Create objects of the 2 required classes
        AssetManager assetManager = getAssets();
        AssetFileDescriptor descriptor;

        //create our three fx in memory ready for use
        descriptor = assetManager.openFd("sample1.ogg");
        sample1 = soundPool.load(descriptor, 0);

        descriptor = assetManager.openFd("sample4.ogg");
        sample4 = soundPool.load(descriptor, 0);


    } catch (IOException e) {
        //catch exceptions here
    }
}
项目:Android-Game-Programming    文件:GameActivity.java   
public void loadSound(){
    soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
    try {
        //Create objects of the 2 required classes
        AssetManager assetManager = getAssets();
        AssetFileDescriptor descriptor;

        //create our three fx in memory ready for use
        descriptor = assetManager.openFd("sample1.ogg");
        sample1 = soundPool.load(descriptor, 0);

        descriptor = assetManager.openFd("sample4.ogg");
        sample4 = soundPool.load(descriptor, 0);


    } catch (IOException e) {
        //catch exceptions here
    }
}
项目:brailleback    文件:FeedbackController.java   
/**
 * Constructs and initializes a new feedback controller.
 */
public FeedbackController(Context context) {
    mContext = context;
    mResources = context.getResources();
    mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
    mSoundPool = new SoundPool(NUMBER_OF_CHANNELS, DEFAULT_STREAM, 1);
    mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
        @Override
        public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
            if (status == 0) {
                synchronized (mPostLoadPlayables) {
                    if (mPostLoadPlayables.contains(sampleId)) {
                        soundPool.play(
                                sampleId, DEFAULT_VOLUME, DEFAULT_VOLUME, 1, 0, DEFAULT_RATE);
                        mPostLoadPlayables.remove(Integer.valueOf(sampleId));
                    }
                }
            }
        }
    });
    mHandler = new Handler();

    mResourceIdToSoundMap.clear();
    mResourceIdToVibrationPatternMap.clear();
    MidiUtils.purgeMidiTempFiles(context);
}
项目:miku    文件:SoundPoolPlayer.java   
private SoundPoolPlayer() {
  soundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, SRC_QUALITY);
  final Handler handler = new Handler(Looper.getMainLooper());
  handler.postDelayed(new Runnable() {
    @Override
    public void run() {
      if (soundPool != null) {
        for (Integer soundId : soundResIdMap.values()) {
          soundPool.unload(soundId);
        }
        soundResIdMap.clear();
      }
      handler.postDelayed(this, RELEASE_RESOURCES_INTERVAL_MS);
    }
  }, RELEASE_RESOURCES_INTERVAL_MS);
}
项目:LemonUtils    文件:SoundPoolUtil.java   
/**
 * 播放一个铃声
 *
 * @param context
 * @param resId   音乐资源ID
 */
public static void soundPlay(Context context, int resId) {
    if (playSound) {
        playCount = 0;
        replease();
        AudioManager am = (AudioManager) context
                .getSystemService(Context.AUDIO_SERVICE);// 实例化
        int audioMaxVolum = am.getStreamMaxVolume(AudioManager.STREAM_SYSTEM);// 音效最大值
        am.setStreamVolume(AudioManager.STREAM_SYSTEM, audioMaxVolum,
                AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
        float audioCurrentVolum = am
                .getStreamVolume(AudioManager.STREAM_SYSTEM);
        volumnRatio = audioCurrentVolum / audioMaxVolum;
        soundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
        soundid = soundPool.load(context, resId, 1);
        soundPool.setOnLoadCompleteListener(new LoadCompleteListener());

    }
}
项目:LemonUtils    文件:SoundPoolUtil.java   
/**
 * 播放一个铃声
 *
 * @param context
 * @param resId   音乐资源ID
 * @param count   循环次数
 */
public static void soundPlay(Context context, int resId, int count) {
    if (playSound) {
        playCount = count;
        replease();
        AudioManager am = (AudioManager) context
                .getSystemService(Context.AUDIO_SERVICE);// 实例化
        int audioMaxVolum = am.getStreamMaxVolume(AudioManager.STREAM_SYSTEM);// 音效最大值
        am.setStreamVolume(AudioManager.STREAM_SYSTEM, audioMaxVolum,
                AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
        float audioCurrentVolum = am
                .getStreamVolume(AudioManager.STREAM_SYSTEM);
        volumnRatio = audioCurrentVolum / audioMaxVolum;

        soundPool = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
        soundid = soundPool.load(context, resId, 1);
        soundPool.setOnLoadCompleteListener(new LoadCompleteListener());
    }
}
项目:Tapad    文件:SoundHelper.java   
private GesturePad getGesturePadFromArray(String soundPaths[],
                                          SoundPool soundPool,
                                          View buttonView,
                                          int color, int colorDef,
                                          Activity activity) {
    Sound sounds[] = new Sound[5];
    for (int i = 0; i < 5; i++) {
        if (i < soundPaths.length) {
            // sounds exists
            sounds[i] = new Sound(soundPool, soundPaths[i], mmr);
        } else {
            // no sound gesture
            sounds[i] = new Sound(soundPool, null, mmr);
        }
    }
    return new GesturePad(sounds, buttonView, color, colorDef, activity);
}
项目:iWorkout    文件:PushUpSoundManager.java   
public PushUpSoundManager(final Activity activity) {

        AudioManager audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
        float actualVolume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
        float maxVolume = (float) audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        currentVolume = actualVolume / maxVolume;
        activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            createSoundPool();
        } else {
            createDepricatedSoundPool();
        }

        sounds.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
            @Override
            public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
                loaded = true;
            }
        });

        popSound = sounds.load(activity, R.raw.pop, 1);
        tenSound = sounds.load(activity, R.raw.ten, 1);
        tadaSound = sounds.load(activity, R.raw.tada, 1);
        counter = 0;
    }
项目:toshi-android-client    文件:SoundManager.java   
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private SoundPool buildSoundPool() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        AudioAttributes audioAttributes = new AudioAttributes.Builder()
                .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
                .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                .build();

        return new SoundPool.Builder()
                .setMaxStreams(MAX_STREAMS)
                .setAudioAttributes(audioAttributes)
                .build();
    }

    return new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
}
项目:TrueTone    文件:SoundManager.java   
public void playSequence(final boolean loop) {
        int midiValue = 0;
        int velocity = 0;
        int instrument = 0;
        String fileName = "dyn_" + midiValue + ".mid";
//        MidiFile.writeNoteFile(midiValue, velocity, fileName, MainActivity.config.tempo.getTempoEvent());
//        MidiFile.writeSingleNoteFile(midiValue,instrument, velocity, fileName, MainActivity.config.tempo.getTempoEvent());
        lastSequenceId = sequenceSoundPool.load(FileManager.getInstance().INTERNAL_PATH + "sequence.mid", 1);
        sequenceSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
            @Override
            public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
                sequenceSoundPool.play(lastSequenceId, 1, 1, 0, (loop ? -1 : 0), 1);
            }
        });

        try {
            mediaPlayer.reset();
            mediaPlayer.setDataSource(FileManager.getInstance().EXTERNAL_PATH + "sequence.mid");
            mediaPlayer.setLooping(loop);
            mediaPlayer.prepare();
            mediaPlayer.start();
        } catch (Exception e) {
            HLog.e("Media Player Failure");
            e.printStackTrace();
        }
    }
项目:playn    文件:AndroidAudio.java   
public AndroidAudio(final AndroidPlatform plat) {
  this.plat = plat;
  this.pool = new SoundPool(plat.activity.maxSimultaneousSounds(),
                            AudioManager.STREAM_MUSIC, 0);
  this.pool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
    public void onLoadComplete(SoundPool soundPool, int soundId, int status) {
      PooledSound sound = loadingSounds.remove(soundId);
      if (sound == null) {
        plat.log().warn("Got load complete for unknown sound [id=" + soundId + "]");
      } else if (status == 0) {
        sound.succeed(soundId);
      } else {
        sound.fail(new Exception("Sound load failed [errcode=" + status + "]"));
      }
    }
  });
}
项目:Camera2    文件:SoundClips.java   
@Override
public void onLoadComplete(SoundPool pool, int soundID, int status) {
    if (status != 0) {
        Log.e(TAG, "loading sound tracks failed (status=" + status + ")");
        for (int i = 0; i < mSoundIDs.length; i++ ) {
            if (mSoundIDs[i] == soundID) {
                mSoundIDs[i] = ID_NOT_LOADED;
                break;
            }
        }
        return;
    }

    for (int i = 0; i < mSoundIDs.length; i++ ) {
        if (mSoundIDs[i] == soundID) {
            mSoundIDReady[i] = true;
            break;
        }
    }

    if (soundID == mSoundIDToPlay) {
        mSoundIDToPlay = ID_NOT_LOADED;
        mSoundPool.play(soundID, 1f, 1f, 0, 0, 1f);
    }
}
项目:talkback    文件:FeedbackControllerApp.java   
@Override
public void playAuditory(int resId, final float rate, float volume) {
    if (!mAuditoryEnabled || resId == 0) return;
    final float adjustedVolume = volume * mVolumeAdjustment;
    int soundId = mSoundIds.get(resId);

    if (soundId != 0) {
        new EarconsPlayTask(mSoundPool, soundId, adjustedVolume, rate).execute();
    } else {
        // The sound could not be played from the cache. Start loading the sound into the
        // SoundPool for future use, and use a listener to play the sound ASAP.
        mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
            @Override
            public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
                if(sampleId !=0) {
                    new EarconsPlayTask(mSoundPool, sampleId, adjustedVolume, rate).execute();
                }
            }
        });
        mSoundIds.put(resId, mSoundPool.load(mContext, resId, 1));
    }
}
项目:sophia    文件:TuxManiaGameState.java   
public TuxManiaGameState() {
        super();

        mSoundEffects = new SoundPool(20, AudioManager.STREAM_MUSIC,100); 
        mBonkId = mSoundEffects.load(GameActivity.activity, R.raw.bass, 1);

        mTuxEntity = new TuxEntity();
        mEntities.add(mTuxEntity);

        mShells = new ArrayList<ShellEntity>();
        mStars = new ArrayList<StarEntity>();
        mExplosions = new ArrayList<ExplosionEntity>();

//      mAudioManager = (AudioManager)Main.activity.getSystemService(Context.AUDIO_SERVICE);

        mBGMusic = MediaPlayer.create(GameActivity.activity, R.raw.polka);
        mBGMusic.setLooping(true);
        mBGMusic.start();
        mDeadMusic = MediaPlayer.create(GameActivity.activity, R.raw.decay);
    }
项目:guitar_guy    文件:MetronomeManager.java   
/**
 * Ctor for the metronome manager class.
 * 
 * @param context
 *            The context used for getting the sound files from the assest.
 */
public MetronomeManager(Context context)
{
    // Create a new instance of the media player to play the ticks.
    m_cSoundPlayer =
            new SoundPool(2, AudioManager.STREAM_MUSIC, 0);

    // Initialize a new timer.
    m_beatTimer = new Timer();

    // Load the tick sound.
    m_nTickSoundId =
            m_cSoundPlayer.load(context,
                    R.raw.metronome_tick, 1);

    // Load the tock sound.
    m_nTockSoundId =
            m_cSoundPlayer.load(context,
                    R.raw.metronome_tock, 1);
}
项目:homescreenarcade    文件:VPSoundpool.java   
public static void initSounds(Context theContext) {
    Log.v(LOG_TAG, "initSounds");
    mContext = theContext;
    mSoundPool = new SoundPool(32, AudioManager.STREAM_RING, 0);
    mSoundPoolMap = new HashMap<Integer, Integer>();
    mAudioManager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
}
项目:Android-Code-Demos    文件:BeatBox.java   
public BeatBox(Context context) {
    //访问Assets需要AssetManager类,可以从Context中获取
    mAssets = context.getAssets();
    // This old constructor is deprecated, but we need it for
    // compatibility
    mSoundPool = new SoundPool(MAX_SOUNDS, AudioManager.STREAM_MUSIC, 0);
    loadSounds();
}
项目:PeSanKita-android    文件:SignalAudioManager.java   
public SignalAudioManager(@NonNull Context context) {
    this.context             = context.getApplicationContext();
    this.incomingRinger      = new IncomingRinger(context);
    this.outgoingRinger      = new OutgoingRinger(context);
    this.soundPool           = new SoundPool(1, AudioManager.STREAM_VOICE_CALL, 0);

    this.connectedSoundId    = this.soundPool.load(context, R.raw.webrtc_completed, 1);
    this.disconnectedSoundId = this.soundPool.load(context, R.raw.webrtc_disconnected, 1);
}
项目:RecyclerWheelPicker    文件:RecyclerWheelPicker.java   
private void initSound() {
    mSoundPool = new SoundPool(50, AudioManager.STREAM_SYSTEM, 5);
    try {
        mSoundPool.load(getContext(), R.raw.wheelpickerkeypress, 1);
    } catch (Exception e) {
    }
}
项目:ESDLA-Quiz    文件:GameActivity.java   
/**
 * SoundPool creator with the new constructor available since API 21
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createNewSoundPool() {
    Log.d(this.getClass().getSimpleName(), "New soundpool constructor");

    AudioAttributes attr = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME)
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build();

    soundPool = new SoundPool.Builder().setMaxStreams(1).setAudioAttributes(attr).build();
    correctSound = soundPool.load(this, R.raw.correct_sound, 1);
    wrongSound = soundPool.load(this, R.raw.wrong_sound, 1);
}
项目:ESDLA-Quiz    文件:GameActivity.java   
/**
 * SoundPool creator with the old constructor for devices with less than API 21
 */
@SuppressWarnings("deprecation")
private void createOldSoundPool() {
    Log.d(this.getClass().getSimpleName(), "old soundpool constructor");

    soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
    correctSound = soundPool.load(this, R.raw.correct_sound, 1);
    wrongSound = soundPool.load(this, R.raw.wrong_sound, 1);
}
项目:betterHotels    文件:SoundManager.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setUpSoundPoolLollipop(){
    soundPool = new SoundPool.Builder()
            .setAudioAttributes(new AudioAttributes.Builder().setContentType(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION).build())
            .setMaxStreams(MAX_STREAMS)
            .build();
}
项目:synesthesiavision    文件:SoundManager.java   
/**
 * Creates a new sound pool.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createNewSoundPool(){
    AudioAttributes attributes = new AudioAttributes.Builder()
            .setUsage(AudioAttributes.USAGE_MEDIA)
            .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
            .build();
    soundPool = new SoundPool.Builder()
            .setAudioAttributes(attributes)
            .setMaxStreams(MAX_STREAMS)
            .build();

    startSoundPool();
}
项目:buildAPKsApps    文件:DecisionMakerActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_decision_maker);

    sounds = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
    popSoundId = sounds.load(DecisionMakerActivity.this, R.raw.pop, 1);
    glassSoundId = sounds.load(DecisionMakerActivity.this, R.raw.glass, 1);

    // TODO Send time interval as activity parameter.
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            roll();
        }
    }, 0, 100);

    sectors[0] = (ImageView) findViewById(R.id.sector01);
    sectors[1] = (ImageView) findViewById(R.id.sector02);
    sectors[2] = (ImageView) findViewById(R.id.sector03);
    sectors[3] = (ImageView) findViewById(R.id.sector04);
    sectors[4] = (ImageView) findViewById(R.id.sector05);
    sectors[5] = (ImageView) findViewById(R.id.sector06);
    sectors[6] = (ImageView) findViewById(R.id.sector07);
    sectors[7] = (ImageView) findViewById(R.id.sector08);

    ((Button) findViewById(R.id.roll))
            .setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    randomSectorIndex = PRNG.nextInt(sectors.length);
                    rollStartTime = System.currentTimeMillis();
                    rollMode = true;
                }
            });
}
项目:Huochexing12306    文件:BgdService2.java   
private void doAlarm() {
    if (mCurrMInfo.isVibrate()){
        mVibrator.vibrate(1000);
    }
    if (mCurrMInfo.isRing()){
        SoundPool soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 5);
        soundPool.load(this, R.raw.ticket_alarm, 1);
        soundPool.play(1, 1, 1, 0, 0, 1);
    }
}
项目:Paper-Melody    文件:PlayActivity.java   
private void initSoundPool() {
    SoundPool.Builder spb = new SoundPool.Builder();
    spb.setMaxStreams(10);
    AudioAttributes.Builder attrBuilder = new AudioAttributes.Builder();
    attrBuilder.setLegacyStreamType(AudioManager.STREAM_MUSIC);
    spb.setAudioAttributes(attrBuilder.build());
    soundPool = spb.build();
}
项目:WxPlane    文件:MySurface.java   
public void init(Context context, AttributeSet attrs){

        holder=getHolder();
        holder.addCallback(this);
        p=new Paint();
        p.setStrokeWidth(1);

        bgp=new Paint();
        bgp.setAntiAlias(true);
        bgp.setStyle(Paint.Style.STROKE);
        bgp.setStrokeWidth(1);

        scorep=new Paint();
        scorep.setColor(Color.parseColor("#996633"));
        scorep.setTextSize(50);
        scorep.setStrokeWidth(10);
        bmyp= BitmapFactory.decodeResource(getResources(), R.drawable.plane);
        bbullet= BitmapFactory.decodeResource(getResources(), R.drawable.bullet);
        botherp= BitmapFactory.decodeResource(getResources(), R.drawable.small);
        Bitmap tmp= BitmapFactory.decodeResource(getResources(), R.drawable.middle);
        otherpbit=new Bitmap[]{botherp,tmp};

        Bitmap tmp1=BitmapFactory.decodeResource(getResources(), R.drawable.bomb1);
        Bitmap tmp2=BitmapFactory.decodeResource(getResources(), R.drawable.bomb2);

        bomb=new Bitmap[]{tmp1,tmp2};
        fire=new int[]{2000,5000};
        SoundPool.Builder sb= new SoundPool.Builder();
        sb.setMaxStreams(2);
        sp=sb.build();
        shootID=sp.load(getContext(),R.raw.shoot,1);
        bombID=sp.load(getContext(),R.raw.explosion,1);
        overID=sp.load(getContext(),R.raw.over,1);
    }
项目:boohee_v5.6    文件:MQSoundPoolManager.java   
private MQSoundPoolManager(Context context) {
    this.mContext = context;
    if (VERSION.SDK_INT >= 21) {
        this.mSoundPool = new Builder().setMaxStreams(1).build();
    } else {
        this.mSoundPool = new SoundPool(1, 3, 0);
    }
    this.mAudioManager = (AudioManager) context.getSystemService("audio");
    this.mSoundSourceMap = new HashMap();
}
项目:AndroidProgramming3e    文件:BeatBox.java   
public BeatBox(Context context) {
    mAssets = context.getAssets();
    // This old constructor is deprecated, but we need it for
    // compatibility.
    //noinspection deprecation
    mSoundPool = new SoundPool(MAX_SOUNDS, AudioManager.STREAM_MUSIC, 0);
    loadSounds();
}
项目:AndroidProgramming3e    文件:BeatBox.java   
public BeatBox(Context context) {
    mAssets = context.getAssets();
    // This old constructor is deprecated, but we need it for
    // compatibility.
    //noinspection deprecation
    mSoundPool = new SoundPool(MAX_SOUNDS, AudioManager.STREAM_MUSIC, 0);
    loadSounds();
}
项目:AndroidProgramming3e    文件:BeatBox.java   
public BeatBox(Context context) {
    mAssets = context.getAssets();
    // This old constructor is deprecated, but we need it for
    // compatibility.
    //noinspection deprecation
    mSoundPool = new SoundPool(MAX_SOUNDS, AudioManager.STREAM_MUSIC, 0);
    loadSounds();
}
项目:AndroidProgramming3e    文件:BeatBox.java   
public BeatBox(Context context) {
    mAssets = context.getAssets();
    // This old constructor is deprecated, but we need it for
    // compatibility.
    //noinspection deprecation
    mSoundPool = new SoundPool(MAX_SOUNDS, AudioManager.STREAM_MUSIC, 0);
    loadSounds();
}
项目:Cable-Android    文件:SignalAudioManager.java   
public SignalAudioManager(@NonNull Context context) {
  this.context             = context.getApplicationContext();
  this.incomingRinger      = new IncomingRinger(context);
  this.outgoingRinger      = new OutgoingRinger(context);
  this.soundPool           = new SoundPool(1, AudioManager.STREAM_VOICE_CALL, 0);

  this.connectedSoundId    = this.soundPool.load(context, R.raw.webrtc_completed, 1);
  this.disconnectedSoundId = this.soundPool.load(context, R.raw.webrtc_disconnected, 1);
}