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


Java AudioManager.STREAM_MUSIC属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:c19354837,项目名称:react-native-system-setting,代码行数:16,代码来源:SystemSetting.java

示例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();
}
 
开发者ID:egglang,项目名称:sonicky,代码行数:16,代码来源:Encoder.java

示例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);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:17,代码来源:VideoPlayer.java

示例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);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:22,代码来源:Sound.java

示例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();
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:13,代码来源:DecodersTest.java

示例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();
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:8,代码来源:BeatBox.java

示例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();
}
 
开发者ID:quaap,项目名称:PhoneFoneFun,代码行数:11,代码来源:MainActivity.java

示例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;
	  }
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:13,代码来源:MediaPlayer.java

示例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();
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:8,代码来源:BeatBox.java

示例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;
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:20,代码来源:SaiyAudioTrack.java

示例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();
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:8,代码来源:TGSourceDataLine.java

示例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);
}
 
开发者ID:ITVlab,项目名称:android-tv-news,代码行数:27,代码来源:ExtractorRendererBuilder.java

示例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();
    }
 
开发者ID:Tai-Kimura,项目名称:VideoApplication,代码行数:40,代码来源:AudioDecoder.java

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

}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:14,代码来源:SpeexDecoder.java

示例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>();
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:12,代码来源:SoundPoolUtils.java


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