zoukankan      html  css  js  c++  java
  • soundpool简介

    package com.itheima.soundpool;

    import android.app.Activity;

    import android.media.AudioManager;

    import android.media.SoundPool;

    import android.os.Bundle;

    import android.view.View;

    public class MainActivity extends Activity {

     private SoundPool soundPool;

     private int soundId;

     @Override

     protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.activity_main);

      /**

       * maxStreams<br>

       * the maximum number of simultaneous streams for this SoundPool object<br>

       * streamType<br>

       * the audio stream type as described in AudioManager For example, game

       * applications will normally use STREAM_MUSIC.<br>

       * srcQuality<br>

       * the sample-rate converter quality. Currently has no effect. Use 0 for

       * the default.

       */

      soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);

      /**

       * context<br>

       * the application context<br>

       * resId<br>

       * the resource ID<br>

       * priority<br>

       * the priority of the sound. Currently has no effect. Use a value of 1

       * for future compatibility.

       */

      soundId = soundPool.load(this, R.raw.office, 1);

     }

     public void click(View view) {

      /**

       * soundID a soundID returned by the load() function <br>

       * leftVolume left volume value (range = 0.0 to 1.0) <br>

       * rightVolume right volume value (range = 0.0 to 1.0) <br>

       * priority stream priority (0 = lowest priority) <br>

       * loop loop mode (0 = no loop, -1 = loop forever) rate playback<br>

       * rate (1.0 = normal playback, range 0.5 to 2.0)

       */

      int soundID = soundId;

      float leftVolume = 1.0f;

      float rightVolume = 1.0f;

      int priority = 0;

      int loop = -1;

      float rate = 1.0f;

      soundPool.play(soundID, leftVolume, rightVolume, priority, loop, rate);

     }

    }

  • 相关阅读:
    动态规划____类数字三角形
    动态规划____编辑距离
    123
    pair queue____多源图广搜
    JAVA练习01
    leetcode — binary-tree-maximum-path-sum
    leetcode — best-time-to-buy-and-sell-stock-iii
    leetcode — best-time-to-buy-and-sell-stock-ii
    leetcode — best-time-to-buy-and-sell-stock
    leetcode — triangle
  • 原文地址:https://www.cnblogs.com/freenovo/p/4469814.html
Copyright © 2011-2022 走看看