当前位置: 首页>>代码示例>>Java>>正文


Java SoundPool.load方法代码示例

本文整理汇总了Java中android.media.SoundPool.load方法的典型用法代码示例。如果您正苦于以下问题:Java SoundPool.load方法的具体用法?Java SoundPool.load怎么用?Java SoundPool.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.SoundPool的用法示例。


在下文中一共展示了SoundPool.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerWithPlayer

import android.media.SoundPool; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:20,代码来源:AudioAction.java

示例2: loadSound

import android.media.SoundPool; //导入方法依赖的package包/类
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
    }
}
 
开发者ID:PacktPublishing,项目名称:Android-Game-Programming,代码行数:20,代码来源:GameActivity.java

示例3: soundPlay

import android.media.SoundPool; //导入方法依赖的package包/类
/**
 * 播放一个铃声
 *
 * @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());
    }
}
 
开发者ID:baby2431,项目名称:LemonUtils,代码行数:26,代码来源:SoundPoolUtil.java

示例4: MetronomeManager

import android.media.SoundPool; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:netanelkl,项目名称:guitar_guy,代码行数:26,代码来源:MetronomeManager.java

示例5: initSound

import android.media.SoundPool; //导入方法依赖的package包/类
private void initSound() {
    mSoundPool = new SoundPool(50, AudioManager.STREAM_SYSTEM, 5);
    try {
        mSoundPool.load(getContext(), R.raw.wheelpickerkeypress, 1);
    } catch (Exception e) {
    }
}
 
开发者ID:devilist,项目名称:RecyclerWheelPicker,代码行数:8,代码来源:RecyclerWheelPicker.java

示例6: createOldSoundPool

import android.media.SoundPool; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:AythaE,项目名称:ESDLA-Quiz,代码行数:12,代码来源:GameActivity.java

示例7: onCreate

import android.media.SoundPool; //导入方法依赖的package包/类
@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;
				}
			});
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:37,代码来源:DecisionMakerActivity.java

示例8: doAlarm

import android.media.SoundPool; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:11,代码来源:BgdService2.java

示例9: loadSoundPool

import android.media.SoundPool; //导入方法依赖的package包/类
/**
 * Loads the audio specified by mediaPath into the given SoundPool and
 * returns the sound id.
 *
 * Note that if the mediaPath is a content URI or an URL, the audio must be
 * copied to a temp file and then loaded from there. This could have
 * performance implications.
 *
 * @param soundPool the SoundPool
 * @param form the Form
 * @param mediaPath the path to the media
 */
public static int loadSoundPool(SoundPool soundPool, Form form, String mediaPath)
    throws IOException {
  MediaSource mediaSource = determineMediaSource(form, mediaPath);
  switch (mediaSource) {
    case ASSET:
      return soundPool.load(getAssetsIgnoreCaseAfd(form,mediaPath), 1);

    case REPL_ASSET:
      return soundPool.load(replAssetPath(mediaPath), 1);

    case SDCARD:
      return soundPool.load(mediaPath, 1);

    case FILE_URL:
      return soundPool.load(fileUrlToFilePath(mediaPath), 1);

    case CONTENT_URI:
    case URL:
      File tempFile = cacheMediaTempFile(form, mediaPath, mediaSource);
      return soundPool.load(tempFile.getAbsolutePath(), 1);

    case CONTACT_URI:
      throw new IOException("Unable to load audio for contact " + mediaPath + ".");
  }

  throw new IOException("Unable to load audio " + mediaPath + ".");
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:40,代码来源:MediaUtil.java

示例10: enterFeedback

import android.media.SoundPool; //导入方法依赖的package包/类
@Override
public void enterFeedback() throws SSJFatalException
{
	if (_evchannel_in == null || _evchannel_in.size() == 0)
	{
		throw new SSJFatalException("no input channels");
	}

	player = new SoundPool(4, AudioManager.STREAM_NOTIFICATION, 0);
	soundId = player.load(options.audioFile.get().value, 1);
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:12,代码来源:AuditoryFeedback.java

示例11: onCreate

import android.media.SoundPool; //导入方法依赖的package包/类
@Override
public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    resolver = getContentResolver();
    map = new HashMap<>();
    con = XmppTool.getInstance().getCon();
    user = SaveUserUtil.loadAccount(XmppService.this).getUser();
    pool = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5);
    pool.load(this, R.raw.tishi, 1);
    vibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
    Log.i("service", "启动服务......");

}
 
开发者ID:jiangzehui,项目名称:xmpp,代码行数:15,代码来源:XmppService.java

示例12: GameView

import android.media.SoundPool; //导入方法依赖的package包/类
public GameView(Context context) {
  super(context);

  parent = (C2B) context;
  lastTarget = 0;
  score = 0;
  comboCount = 0;
  longestCombo = 0;
  lastRating = "";

  drawnTargets = new ArrayList<Target>();
  recordedTargets = new ArrayList<Target>();

  vibe = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

  snd = new SoundPool(10, AudioManager.STREAM_SYSTEM, 0);
  missSfx = snd.load(context, R.raw.miss, 0);
  hitOkSfx = snd.load(context, R.raw.ok, 0);
  hitPerfectSfx = snd.load(context, R.raw.perfect, 0);

  innerPaint = new Paint();
  innerPaint.setColor(Color.argb(127, 0, 0, 0));
  innerPaint.setStyle(Paint.Style.FILL);
  borderPaint = new Paint();
  borderPaint.setStyle(Paint.Style.STROKE);
  borderPaint.setAntiAlias(true);
  borderPaint.setStrokeWidth(2);
  haloPaint = new Paint();
  haloPaint.setStyle(Paint.Style.STROKE);
  haloPaint.setAntiAlias(true);
  haloPaint.setStrokeWidth(4);

  Thread monitorThread = (new Thread(new Monitor()));
  monitorThread.setPriority(Thread.MIN_PRIORITY);
  monitorThread.start();
}
 
开发者ID:tgmarinho,项目名称:apps-for-android,代码行数:37,代码来源:GameView.java

示例13: onCreate

import android.media.SoundPool; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    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("sample2.ogg");
        sample2 = soundPool.load(descriptor, 0);


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


    }catch(IOException e){
        //catch exceptions here
    }

    //Make a button from each of the buttons in our layout
    Button button1 =(Button) findViewById(R.id.button);
    Button button2 =(Button) findViewById(R.id.button2);
    Button button3 =(Button) findViewById(R.id.button3);

    //Make each of them listen for clicks
    button1.setOnClickListener(this);
    button2.setOnClickListener(this);
    button3.setOnClickListener(this);


}
 
开发者ID:PacktPublishing,项目名称:Android-Game-Programming,代码行数:40,代码来源:MainActivity.java

示例14: MediaController

import android.media.SoundPool; //导入方法依赖的package包/类
private MediaController() {
    try {
        sensorManager = (SensorManager) MainApp.CONTEXT.getSystemService(Context.SENSOR_SERVICE);
        proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
        soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
        soundEffectId = soundPool.load(MainApp.CONTEXT, R.raw.add, 1);
    } catch (Exception e) {
        Logger.e(TAG, "Sensor init error", e);
    }
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:11,代码来源:MediaController.java

示例15: GameLogic

import android.media.SoundPool; //导入方法依赖的package包/类
public GameLogic(Context context, int ID) {
	blockMap = new BlockMap(context);
	blockMap.selectMap(ID);
	nowLevelID=ID;
	
	audio=new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
	audio_res=audio.load(context, R.raw.tick,1);
	initBlock();
}
 
开发者ID:VMatrices,项目名称:CubeMatrix,代码行数:10,代码来源:GameLogic.java


注:本文中的android.media.SoundPool.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。