本文整理汇总了Java中android.media.AudioManager.STREAM_MUSIC属性的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.STREAM_MUSIC属性的具体用法?Java AudioManager.STREAM_MUSIC怎么用?Java AudioManager.STREAM_MUSIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.STREAM_MUSIC属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVolType
private int getVolType(String type) {
switch (type) {
case VOL_VOICE_CALL:
return AudioManager.STREAM_VOICE_CALL;
case VOL_SYSTEM:
return AudioManager.STREAM_SYSTEM;
case VOL_RING:
return AudioManager.STREAM_RING;
case VOL_ALARM:
return AudioManager.STREAM_ALARM;
case VOL_NOTIFICATION:
return AudioManager.STREAM_NOTIFICATION;
default:
return AudioManager.STREAM_MUSIC;
}
}
示例2: init_
private void init_(boolean eccEnabled) {
mEccEncoder = EccInstanceProvider.getEncoder(eccEnabled);
int minBufferSizeInBytes = AudioTrack.getMinBufferSize(
RATE,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT);
// 44.1kHz mono 16bit
mAudioTrack = new AudioTrack(
AudioManager.STREAM_MUSIC,
RATE,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
minBufferSizeInBytes,
AudioTrack.MODE_STREAM);
mExecutorService = Executors.newSingleThreadExecutor();
}
示例3: buildRenderers
@Override
public void buildRenderers(VideoPlayer player) {
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
Handler mainHandler = player.getMainHandler();
TrackRenderer[] renderers = new TrackRenderer[RENDERER_COUNT];
DataSource dataSource = new DefaultUriDataSource(context, userAgent);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator, BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, mainHandler, null, 0);
renderers[TYPE_VIDEO] = new MediaCodecVideoTrackRenderer(context, sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50) {
@Override
protected void doSomeWork(long positionUs, long elapsedRealtimeUs, boolean sourceIsReady) throws ExoPlaybackException {
super.doSomeWork(positionUs, elapsedRealtimeUs, sourceIsReady);
}
};
renderers[TYPE_AUDIO] = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT, null, true, mainHandler, null, AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
player.onRenderers(renderers);
}
示例4: Sound
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);
}
}
示例5: audioDecoderTest
public void audioDecoderTest(String filePath) throws IOException {
AudioDecoder audioDecoderThread = new AudioDecoder(this, this);
audioDecoderThread.initExtractor(filePath);
audioDecoderThread.prepareAudio();
int buffsize = AudioTrack.getMinBufferSize(audioDecoderThread.getSampleRate(),
AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT);
audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, audioDecoderThread.getSampleRate(),
AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT, buffsize,
AudioTrack.MODE_STREAM);
audioTrack.play();
audioDecoderThread.start();
}
示例6: BeatBox
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();
}
示例7: onResume
@Override
protected void onResume() {
super.onResume();
ttv = new TextToVoice(this);
tonegen = new ToneGenerator(AudioManager.STREAM_MUSIC, 99);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
if (mSensor!=null) {
mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
speakTimer = new Timer();
}
示例8: audioTrackInit
public int audioTrackInit() {
// Log.e(" ffff mediaplayer audiotrackinit start . sampleRateInHz:=" + sampleRateInHz + " channels:=" + channels );
audioTrackRelease();
int channelConfig = channels >= 2 ? AudioFormat.CHANNEL_OUT_STEREO : AudioFormat.CHANNEL_OUT_MONO;
try {
mAudioTrackBufferSize = AudioTrack.getMinBufferSize(sampleRateInHz, channelConfig, AudioFormat.ENCODING_PCM_16BIT);
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRateInHz, channelConfig, AudioFormat.ENCODING_PCM_16BIT, mAudioTrackBufferSize, AudioTrack.MODE_STREAM);
} catch (Exception e) {
mAudioTrackBufferSize = 0;
Log.e("audioTrackInit", e);
}
return mAudioTrackBufferSize;
}
示例9: BeatBox
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();
}
示例10: getSaiyAudioTrack
/**
* Static helper method to create a {@link SaiyAudioTrack} object, as the Constructor parameters
* will always be the same.
*
* @return a new {@link SaiyAudioTrack} object
*/
public static SaiyAudioTrack getSaiyAudioTrack() {
try {
return new SaiyAudioTrack(AudioManager.STREAM_MUSIC, SaiyAudioTrack.SAMPLE_RATE_HZ,
SaiyAudioTrack.CHANNEL_OUT, SaiyAudioTrack.ENCODING, SaiyAudioTrack.MIN_BUFFER_SIZE,
SaiyAudioTrack.MODE_STREAM);
} catch (final IllegalArgumentException e) {
if (DEBUG) {
MyLog.w(CLS_NAME, "getSaiyAudioTrack: IllegalArgumentException");
e.printStackTrace();
}
return null;
}
}
示例11: open
@Override
public void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
this.bufferSize = DEFAULT_BUFFER_SIZE;//bufferSize;
this.format = new TGAudioFormat(format);
this.audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, this.format.getSampleRateInHz(), this.format.getChannelConfig(), this.format.getAudioFormat(), this.bufferSize, AudioTrack.MODE_STREAM);
super.open();
}
示例12: buildRenderers
@Override
public void buildRenderers(VideoPlayer player) {
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
// Build the video and audio renderers.
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(),
null);
DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
sampleSource, MediaCodecSelector.DEFAULT,
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
player.getMainHandler(), player, 50);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
MediaCodecSelector.DEFAULT, null, true, player.getMainHandler(), player,
AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
player.getMainHandler().getLooper());
// Invoke the callback.
TrackRenderer[] renderers = new TrackRenderer[VideoPlayer.RENDERER_COUNT];
renderers[VideoPlayer.TYPE_VIDEO] = videoRenderer;
renderers[VideoPlayer.TYPE_AUDIO] = audioRenderer;
renderers[VideoPlayer.TYPE_TEXT] = textRenderer;
player.onRenderers(renderers, bandwidthMeter);
}
示例13: prepare
@Override
protected void prepare() throws IOException {
if (mState < STATE_PREPARED) {
MediaFormat format;
if (mState == STATE_UNINITIALIZED) {
mTrackIndex = selectTrack();
if (mTrackIndex < 0) {
setState(STATE_NO_TRACK_FOUND);
return;
}
mExtractor.selectTrack(mTrackIndex);
format = mExtractor.getTrackFormat(mTrackIndex);
mSampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
int audioChannels = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
mAudioTrack = new AudioTrack(
AudioManager.STREAM_MUSIC,
mSampleRate,
(audioChannels == 1 ? AudioFormat.CHANNEL_OUT_MONO : AudioFormat.CHANNEL_OUT_STEREO),
AudioFormat.ENCODING_PCM_16BIT,
AudioTrack.getMinBufferSize(
mSampleRate,
(audioChannels == 1 ? AudioFormat.CHANNEL_OUT_MONO : AudioFormat.CHANNEL_OUT_STEREO),
AudioFormat.ENCODING_PCM_16BIT
),
AudioTrack.MODE_STREAM
);
mState = STATE_INITIALIZED;
} else {
format = mExtractor.getTrackFormat(mTrackIndex);
}
String mime = format.getString(MediaFormat.KEY_MIME);
Log.d(TAG, mime);
mMediaCodec = MediaCodec.createDecoderByType(mime);
// mMediaCodec.setCallback(mCallback);
mMediaCodec.configure(format, null, null, 0);
setState(STATE_PREPARED);
}
super.prepare();
}
示例14: initializeAndroidAudio
private void initializeAndroidAudio(int sampleRate) throws Exception {
int minBufferSize = AudioTrack.getMinBufferSize(sampleRate,
AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT);
if (minBufferSize < 0) {
throw new Exception("Failed to get minimum buffer size: "
+ Integer.toString(minBufferSize));
}
track = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT,
minBufferSize, AudioTrack.MODE_STREAM);
}
示例15: initAudioManager
/**
* 初始化音频管理器
*
* @param context
*/
private void initAudioManager(Context context)
{
mContext = context.getApplicationContext();
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
mSoundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
mSoundPoolMap = new HashMap<String, Integer>();
}