本文整理汇总了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();
}
示例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();
}
示例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);
}
}
示例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());
}
}
});
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}
});
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例14: playShutterSound
import android.media.MediaActionSound; //导入依赖的package包/类
private void playShutterSound() {
MediaActionSound sound = new MediaActionSound();
sound.play(MediaActionSound.SHUTTER_CLICK);
}
示例15: playFocusSound
import android.media.MediaActionSound; //导入依赖的package包/类
private void playFocusSound() {
MediaActionSound sound = new MediaActionSound();
sound.play(MediaActionSound.FOCUS_COMPLETE);
}