Android播放照相机声音

    用华硕的一个Android 3.1平板电脑测试的时候。发现拍照没有声音。

  由于需求需要加上声音,只好自己播放系统的照相机声音。

	/**
	 *   播放系统拍照声音
	 */
	public void shootSound()
	{
	    AudioManager meng = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
	    int volume = meng.getStreamVolume( AudioManager.STREAM_NOTIFICATION);

	    if (volume != 0)
	    {
	        if (shootMP == null)
	            shootMP = MediaPlayer.create(getContext(), Uri.parse("file:///system/media/audio/ui/camera_click.ogg"));
	        if (shootMP != null)
	            shootMP.start();
	    }
	}
   其中shootMP为MediaPlayer。

   在拍照时,调用这个播放就行了。


  

posted @ 2011-08-03 13:09  java例子  阅读(1249)  评论(0编辑  收藏  举报