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


Java MediaActionSound类代码示例

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


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

示例1: onClick

import android.media.MediaActionSound; //导入依赖的package包/类
@Override
public void onClick(View view) {
    if (System.currentTimeMillis() - lastClickTime < CLICK_DELAY) {
        return;
    } else lastClickTime = System.currentTimeMillis();

    if (Build.VERSION.SDK_INT > 15) {
        MediaActionSound sound = new MediaActionSound();
        if (TAKE_PHOTO_STATE == currentState) {
            takePhoto(sound);
        } else if (READY_FOR_RECORD_STATE == currentState) {
            startRecording(sound);
        } else if (RECORD_IN_PROGRESS_STATE == currentState) {
            stopRecording(sound);
        }
    } else {
        if (TAKE_PHOTO_STATE == currentState) {
            takePhoto();
        } else if (READY_FOR_RECORD_STATE == currentState) {
            startRecording();
        } else if (RECORD_IN_PROGRESS_STATE == currentState) {
            stopRecording();
        }
    }
    setIcon();
}
 
开发者ID:sandrios,项目名称:sandriosCamera,代码行数:27,代码来源:RecordButton.java

示例2: takeSnapshot

import android.media.MediaActionSound; //导入依赖的package包/类
private void takeSnapshot()
{
	// get the snapshot image
	Bitmap image = textureView.getBitmap();

	// save the image
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss");
	String name = camera.network + "_" + camera.name.replaceAll("\\s+", "") + "_" + sdf.format(new Date()) + ".jpg";
	Utils.saveImage(getActivity().getContentResolver(), image, name, null);
	Log.info("takeSnapshot: " + name);

	// play the shutter sound
	MediaActionSound sound = new MediaActionSound();
	sound.play(MediaActionSound.SHUTTER_CLICK);

	// display a message
	String msg = String.format(getString(R.string.image_saved), getString(R.string.app_name));
	Toast toast = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT);
	toast.show();
}
 
开发者ID:ShawnBaker,项目名称:RPiCameraViewer,代码行数:21,代码来源:VideoFragment.java

示例3: play

import android.media.MediaActionSound; //导入依赖的package包/类
@Override
public synchronized void play(int action) {
    switch(action) {
        case FOCUS_COMPLETE:
            mSound.play(MediaActionSound.FOCUS_COMPLETE);
            break;
        case START_VIDEO_RECORDING:
            mSound.play(MediaActionSound.START_VIDEO_RECORDING);
            break;
        case STOP_VIDEO_RECORDING:
            mSound.play(MediaActionSound.STOP_VIDEO_RECORDING);
            break;
        case SHUTTER_CLICK:
            mSound.play(MediaActionSound.SHUTTER_CLICK);
            break;
        default:
            Log.w(TAG, "Unrecognized action:" + action);
    }
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:20,代码来源:SoundClips.java

示例4: captureScreenshotAsync

import android.media.MediaActionSound; //导入依赖的package包/类
/**
 * capture the map as an image
 */
private void captureScreenshotAsync() {

    // export the image from the mMapView
    final ListenableFuture<Bitmap> export = mMapView.exportImageAsync();
    export.addDoneListener(new Runnable() {
        @Override
        public void run() {
            try {
                Bitmap currentMapImage = export.get();
                // play the camera shutter sound
                MediaActionSound sound = new MediaActionSound();
                sound.play(MediaActionSound.SHUTTER_CLICK);
                Log.d(TAG,"Captured the image!!");
                // save the exported bitmap to an image file
                SaveImageTask saveImageTask = new SaveImageTask();
                saveImageTask.execute(currentMapImage);
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), getResources().getString(R.string.map_export_failure) + e.getMessage(), Toast.LENGTH_SHORT).show();
                Log.e(TAG, getResources().getString(R.string.map_export_failure) + e.getMessage());
            }
        }
    });
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:27,代码来源:MainActivity.java

示例5: takePhoto

import android.media.MediaActionSound; //导入依赖的package包/类
protected void takePhoto(CameraFragmentResultListener callback, @Nullable String directoryPath, @Nullable String fileName) {
    if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) {
        new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK);
    }
    setRecordState(Record.TAKE_PHOTO_STATE);
    this.cameraController.takePhoto(callback, directoryPath, fileName);
    if (cameraFragmentStateListener != null) {
        cameraFragmentStateListener.onRecordStatePhoto();
    }
}
 
开发者ID:florent37,项目名称:CameraFragment,代码行数:11,代码来源:BaseAnncaFragment.java

示例6: startRecording

import android.media.MediaActionSound; //导入依赖的package包/类
protected void startRecording(@Nullable String directoryPath, @Nullable String fileName) {
    if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) {
        new MediaActionSound().play(MediaActionSound.START_VIDEO_RECORDING);
    }

    setRecordState(Record.RECORD_IN_PROGRESS_STATE);
    this.cameraController.startVideoRecord(directoryPath, fileName);

    if (cameraFragmentStateListener != null) {
        cameraFragmentStateListener.onRecordStateVideoInProgress();
    }
}
 
开发者ID:florent37,项目名称:CameraFragment,代码行数:13,代码来源:BaseAnncaFragment.java

示例7: stopRecording

import android.media.MediaActionSound; //导入依赖的package包/类
protected void stopRecording(CameraFragmentResultListener callback) {
    if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) {
        new MediaActionSound().play(MediaActionSound.STOP_VIDEO_RECORDING);
    }

    setRecordState(Record.READY_FOR_RECORD_STATE);
    this.cameraController.stopVideoRecord(callback);

    this.onStopVideoRecord(callback);

    if (cameraFragmentStateListener != null) {
        cameraFragmentStateListener.onRecordStateVideoReadyForRecord();
    }
}
 
开发者ID:florent37,项目名称:CameraFragment,代码行数:15,代码来源:BaseAnncaFragment.java

示例8: CameraTwoEngine

import android.media.MediaActionSound; //导入依赖的package包/类
/**
 * Standard constructor
 *
 * @param ctxt any Context will do
 */
public CameraTwoEngine(Context ctxt) {
  mgr=(CameraManager)ctxt.
      getApplicationContext().
      getSystemService(Context.CAMERA_SERVICE);
  handlerThread.start();
  handler=new Handler(handlerThread.getLooper());
  shutter.load(MediaActionSound.SHUTTER_CLICK);
}
 
开发者ID:code-mc,项目名称:FacerecognitionFlowpilots,代码行数:14,代码来源:CameraTwoEngine.java

示例9: takePicture

import android.media.MediaActionSound; //导入依赖的package包/类
void takePicture(){
    if(mCameraSource != null){
        mCameraSource.takePicture(new CameraSource.ShutterCallback() {
            @Override
            public void onShutter() {
                sound.play(MediaActionSound.SHUTTER_CLICK);
            }
        }, new CameraSource.PictureCallback() {
            @Override
            public void onPictureTaken(byte[] data) {
                detectDocumentManually(data);
            }
        });
    }
}
 
开发者ID:Credntia,项目名称:CVScanner,代码行数:16,代码来源:DocumentScannerFragment.java

示例10: MediaActionSoundPlayer

import android.media.MediaActionSound; //导入依赖的package包/类
public MediaActionSoundPlayer() {
    mSound = new MediaActionSound();
    mSound.load(MediaActionSound.START_VIDEO_RECORDING);
    mSound.load(MediaActionSound.STOP_VIDEO_RECORDING);
    mSound.load(MediaActionSound.FOCUS_COMPLETE);
    mSound.load(MediaActionSound.SHUTTER_CLICK);
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:8,代码来源:SoundClips.java

示例11: onAutoFocus

import android.media.MediaActionSound; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onAutoFocus(boolean success, Camera camera) {
  if (success
      && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    new MediaActionSound().play(MediaActionSound.FOCUS_COMPLETE);
  }
}
 
开发者ID:nimengbo,项目名称:MyCamera,代码行数:9,代码来源:SimpleCameraHost.java

示例12: CameraTwoEngine

import android.media.MediaActionSound; //导入依赖的package包/类
/**
 * Standard constructor
 *
 * @param ctxt any Context will do
 */
public CameraTwoEngine(Context ctxt) {
  this.ctxt=ctxt.getApplicationContext();
  mgr=(CameraManager)this.ctxt.
      getSystemService(Context.CAMERA_SERVICE);
  handlerThread.start();
  handler=new Handler(handlerThread.getLooper());
  shutter.load(MediaActionSound.SHUTTER_CLICK);
}
 
开发者ID:commonsguy,项目名称:cwac-cam2,代码行数:14,代码来源:CameraTwoEngine.java

示例13: onCaptureStarted

import android.media.MediaActionSound; //导入依赖的package包/类
@Override
public void onCaptureStarted(CameraCaptureSession session,
                             CaptureRequest request,
                             long timestamp, long frameNumber) {
  super.onCaptureStarted(session, request, timestamp, frameNumber);

  shutter.play(MediaActionSound.SHUTTER_CLICK);
}
 
开发者ID:commonsguy,项目名称:cwac-cam2,代码行数:9,代码来源:CameraTwoEngine.java

示例14: playShutterSound

import android.media.MediaActionSound; //导入依赖的package包/类
private void playShutterSound() {
    MediaActionSound sound = new MediaActionSound();
    sound.play(MediaActionSound.SHUTTER_CLICK);
}
 
开发者ID:akexorcist,项目名称:CameraSample,代码行数:5,代码来源:CameraV1Activity.java

示例15: playFocusSound

import android.media.MediaActionSound; //导入依赖的package包/类
private void playFocusSound() {
    MediaActionSound sound = new MediaActionSound();
    sound.play(MediaActionSound.FOCUS_COMPLETE);
}
 
开发者ID:akexorcist,项目名称:CameraSample,代码行数:5,代码来源:CameraV1Activity.java


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