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);

     }

    }

  • 相关阅读:
    【原创】2013个人年终总结
    【原创】关于部门月会(二)
    【原创】关于部门月会(一)
    [转载]使用RoboCopy 命令
    ubuntu 16.04.3 安装完成后的一些初始化工作
    umbraco v7.6.4 surface controller not found 大深坑!
    ubuntu 及 postgredql 安装配置小坑摘录
    flex hack 记录
    C# 中的委托和事件
    OVER(PARTITION BY)函数介绍
  • 原文地址:https://www.cnblogs.com/freenovo/p/4469814.html
Copyright © 2011-2022 走看看