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


Java OnLoadCompleteListener类代码示例

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


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

示例1: playSound

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:MQSoundPoolManager.java

示例2: FeedbackController

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:google,项目名称:brailleback,代码行数:29,代码来源:FeedbackController.java

示例3: playSequence

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
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();
        }
    }
 
开发者ID:Ag47,项目名称:TrueTone,代码行数:27,代码来源:SoundManager.java

示例4: playAuditory

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
@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));
    }
}
 
开发者ID:google,项目名称:talkback,代码行数:23,代码来源:FeedbackControllerApp.java

示例5: play

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
public static void play(final int soundId,
		final PlaySoundCompletionListener playSoundCompletionListener) {
	if (sounds.get(soundId) != null) {
		int soundID1 = sounds.get(soundId);
		beginPlay(soundID1, playSoundCompletionListener);
	} else {
		synchronized (sounds) {
			final int soundIDOfPool = soundPool.load(
					BitherApplication.mContext, soundId, 1);
			soundPool
					.setOnLoadCompleteListener(new OnLoadCompleteListener() {
						@Override
						public void onLoadComplete(SoundPool arg0,
								int arg1, int arg2) {
							if (arg1 == soundIDOfPool) {
								beginPlay(soundIDOfPool,
										playSoundCompletionListener);
							}
						}
					});
			LogUtil.d("record", "load:" + soundId);
			sounds.put(soundId, soundIDOfPool);
		}
	}
}
 
开发者ID:bither,项目名称:bither-android,代码行数:26,代码来源:PlaySound.java

示例6: setupSound

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
private void setupSound() 
{		
	spool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
	spool.setOnLoadCompleteListener(new OnLoadCompleteListener() 
	{

		@Override
		public void onLoadComplete(SoundPool soundPool, int sampleId, int status) 
		{
			if(status==0)
			{
				if(sampleId==soundID)
					canPlaySound = true;
			}				
		}
	});


	soundID = spool.load(getApplicationContext(), R.raw.one_click, 1);
}
 
开发者ID:vocefiscal,项目名称:vocefiscal-android,代码行数:21,代码来源:CameraActivity.java

示例7: onResume

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
/** State where the UI becomes visible and the user can start interacting.*/
	@Override
	protected void onResume() {
		super.onResume();
//		log("onResume");		

		// Manage bubble popping sound. Use AudioManager.STREAM_MUSIC as stream type
		mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

		mStreamVolume = (float) mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) / mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); //divide by is the forward.

		mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); //0 is currently not implemented by Google.

		mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
			@Override
			public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
				if (status == 0) {
//					log("onLoadComplete sound");					
					setupGestureDetector();
				}
			}
		});
		
		mSoundID = mSoundPool.load(this, R.raw.bubble_pop, 1); //load the sound from res/raw/bubble_pop.wav		
	}
 
开发者ID:ariesmcrae,项目名称:AndroidEskwela,代码行数:26,代码来源:BubbleActivity.java

示例8: playViaSoundPool

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
public static void playViaSoundPool(Context context, final int resId) {
	// AudioAttributes.Builder attrBuilder = new AudioAttributes.Builder();
	// attrBuilder.setLegacyStreamType(AudioManager.STREAM_NOTIFICATION);
	// attrBuilder.setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT);
	// attrBuilder.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION);
	//
	// SoundPool.Builder spBuilder = new SoundPool.Builder();
	// spBuilder.setMaxStreams(2);
	// spBuilder.setAudioAttributes(attrBuilder.build());
	//
	// SoundPool sp21 = spBuilder.build();

	int maxStreams = 5, streamType = AudioManager.STREAM_NOTIFICATION, srcQuality = 0;
	@SuppressWarnings("deprecation")
	final SoundPool sp20 = new SoundPool(maxStreams, streamType, srcQuality);

	int priority = 1;
	final int soundId = sp20.load(context, resId, priority);

	// soundID : a soundID returned by the load() function
	// leftVolume : left volume value (range = 0.0 to 1.0), 左声道
	// rightVolume : right volume value (range = 0.0 to 1.0), 右声道
	// priority : stream priority (0 = lowest priority), 优先级
	// loop : loop mode (0 = no loop, -1 = loop forever), 循环与否
	// rate : playback rate (1.0 = normal playback, range 0.5 to 2.0), 播放返回的速度
	final float leftVolume = 1, rightVolume = 1;
	final int playPriority = 0, loop = 0;
	final float rate = 1.0F;

	sp20.setOnLoadCompleteListener(new OnLoadCompleteListener() {
		@Override
		public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
			int streamID = sp20.play(soundId, leftVolume, rightVolume, playPriority, loop, rate);

			if (streamID == 0 || status != 0) {
				LogUtil.e("Play sound " + resId + " fail.");
			}
		}
	});
}
 
开发者ID:imknown,项目名称:IMKBaseFrameworkLibrary,代码行数:41,代码来源:MusicMediaPlayerUtil.java

示例9: onResume

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
@Override
protected void onResume() {
	super.onResume();

	// Manage bubble popping sound
	// Use AudioManager.STREAM_MUSIC as stream type

	mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

	mStreamVolume = (float) mAudioManager
			.getStreamVolume(AudioManager.STREAM_MUSIC)
			/ mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

	// Make a new SoundPool, allowing up to 10 streams
	mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);

	// TODO - Set a SoundPool OnLoadCompletedListener that calls
	// setupGestureDetector()
	mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
		@Override
		public void onLoadComplete(SoundPool soundPool, int sampleId,
				int status) {

           }
	});

	// TODO - Load the sound from res/raw/bubble_pop.wav
       mSoundID = 0;

}
 
开发者ID:aporter,项目名称:umd-android-labs,代码行数:31,代码来源:BubbleActivity.java

示例10: onResume

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
@Override
protected void onResume() {
	super.onResume();

	// Manage bubble popping sound
	// Use AudioManager.STREAM_MUSIC as stream type

	mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

	mStreamVolume = (float) mAudioManager
			.getStreamVolume(AudioManager.STREAM_MUSIC)
			/ mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

	// TODO - make a new SoundPool, allowing up to 10 streams 
	mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);

	// TODO - set a SoundPool OnLoadCompletedListener that calls setupGestureDetector()
	mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
		@Override
		public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
		
			if (0 == status) {
					setupGestureDetector();
			}
		}
	});
	
	// TODO - load the sound from res/raw/bubble_pop.wav
	mSoundID = mSoundPool.load(this, R.raw.bubble_pop, 1);

}
 
开发者ID:alepapadop,项目名称:android_coursera_1,代码行数:32,代码来源:BubbleActivity.java

示例11: onResume

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
@Override
protected void onResume() {
	super.onResume();
	Log.d(TAG, "In onResume()...");
	
	// Manage bubble popping sound
	// Use AudioManager.STREAM_MUSIC as stream type

	mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

	mStreamVolume = (float) mAudioManager
			.getStreamVolume(AudioManager.STREAM_MUSIC)
			/ mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

	// TODO - make a new SoundPool, allowing up to 10 streams
	mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);

	// TODO - set a SoundPool OnLoadCompletedListener that calls
	// setupGestureDetector()
	mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {

		@Override
		public void onLoadComplete(SoundPool soundPool, int sampleId,
				int status) {
			Log.d(TAG, "SoundPool has finished loading sound " + sampleId);
			setupGestureDetector();
		}
	});
	
	// TODO - load the sound from res/raw/bubble_pop.wav
	mSoundID = mSoundPool.load(this, R.raw.bubble_pop, 1);
}
 
开发者ID:mfitz,项目名称:android-002,代码行数:33,代码来源:BubbleActivity.java

示例12: initializeSounds

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
private void initializeSounds() {
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    // Load sounds
    mSoundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
    mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
        @Override
        public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
            mLoaded = true;
        }
    });
    mSoundConnect = mSoundPool.load(this, R.raw.proxima, 1);
    mSoundDisconnect = mSoundPool.load(this, R.raw.tejat, 1);
}
 
开发者ID:bitcraze,项目名称:crazyflie-android-client,代码行数:14,代码来源:MainActivity.java

示例13: onCreate

import android.media.SoundPool.OnLoadCompleteListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	mView = new GL2JNIView(getApplication());
	mView.setOnTouchListener(this);
	Display display = getWindowManager().getDefaultDisplay();
	display.getSize(size);
	this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
	lib.setContext(this);
	lib.setSoundPool(new SoundPool(10, AudioManager.STREAM_MUSIC, 0));
	lib.getSoundPool().setOnLoadCompleteListener(new OnLoadCompleteListener() {
		@Override
		public void onLoadComplete(SoundPool soundPool, int sampleId,
				int status) {
			lib.setLoaded(true);
		}
	});
	lib.setSoundIDA(lib.getSoundPool().load(this, R.raw.a, 1));
	lib.setSoundIDB(lib.getSoundPool().load(this, R.raw.b, 1));
	lib.setSoundIDG(lib.getSoundPool().load(this, R.raw.g, 1));
	lib.setSoundIDCSharp(lib.getSoundPool().load(this, R.raw.cs, 1));
	lib.setSoundIDC(lib.getSoundPool().load(this, R.raw.cs, 1));
	lib.setSoundIDD(lib.getSoundPool().load(this, R.raw.d, 1));
	lib.setSoundIDE(lib.getSoundPool().load(this, R.raw.e, 1));
	lib.setSoundIDFSharp(lib.getSoundPool().load(this, R.raw.fs, 1));
	lib.setAudioManager((AudioManager) getSystemService(AUDIO_SERVICE));
	setContentView(mView);
}
 
开发者ID:jrgleason,项目名称:SimpleAndroidGLPiano,代码行数:29,代码来源:GL2JNIActivity.java


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