Fixed clicks

pull/17/head
Florent CHAMPIGNY 8 years ago
parent 1c219d40f0
commit 11d4958461
  1. 2
      app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java
  2. BIN
      art/default_camera.png
  3. BIN
      art/settings_for_video_limitation.png
  4. BIN
      art/video_camera.png
  5. BIN
      art/video_low_quality.png
  6. 156
      camerafragment/src/main/java/com/github/florent37/camerafragment/PreviewActivity.java

@ -102,7 +102,7 @@ public class MainActivity extends AppCompatActivity {
} }
} }
@OnClick(R.id.settings_view) @OnClick(R.id.photo_video_camera_switcher)
public void onMediaActionSwitchClicked(){ public void onMediaActionSwitchClicked(){
final CameraFragmentApi cameraFragment = getCameraFragment(); final CameraFragmentApi cameraFragment = getCameraFragment();
if (cameraFragment != null) { if (cameraFragment != null) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

@ -67,91 +67,13 @@ public class PreviewActivity extends AppCompatActivity implements View.OnClickLi
private float[] ratios; private float[] ratios;
private String[] ratioLabels; private String[] ratioLabels;
private SurfaceHolder.Callback surfaceCallbacks = new SurfaceHolder.Callback() { public static Intent newIntentPhoto(Context context, String filePath) {
@Override
public void surfaceCreated(SurfaceHolder holder) {
showVideoPreview(holder);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
};
private MediaController.MediaPlayerControl MediaPlayerControlImpl = new MediaController.MediaPlayerControl() {
@Override
public void start() {
mediaPlayer.start();
}
@Override
public void pause() {
mediaPlayer.pause();
}
@Override
public int getDuration() {
return mediaPlayer.getDuration();
}
@Override
public int getCurrentPosition() {
return mediaPlayer.getCurrentPosition();
}
@Override
public void seekTo(int pos) {
mediaPlayer.seekTo(pos);
}
@Override
public boolean isPlaying() {
return mediaPlayer.isPlaying();
}
@Override
public int getBufferPercentage() {
return 0;
}
@Override
public boolean canPause() {
return true;
}
@Override
public boolean canSeekBackward() {
return true;
}
@Override
public boolean canSeekForward() {
return true;
}
@Override
public int getAudioSessionId() {
return mediaPlayer.getAudioSessionId();
}
};
public static Intent newIntentPhoto(Context context,
String filePath) {
return new Intent(context, PreviewActivity.class) return new Intent(context, PreviewActivity.class)
.putExtra(MEDIA_ACTION_ARG, MediaAction.ACTION_PHOTO) .putExtra(MEDIA_ACTION_ARG, MediaAction.ACTION_PHOTO)
.putExtra(FILE_PATH_ARG, filePath); .putExtra(FILE_PATH_ARG, filePath);
} }
public static Intent newIntentVideo(Context context, public static Intent newIntentVideo(Context context, String filePath) {
String filePath) {
return new Intent(context, PreviewActivity.class) return new Intent(context, PreviewActivity.class)
.putExtra(MEDIA_ACTION_ARG, MediaAction.ACTION_VIDEO) .putExtra(MEDIA_ACTION_ARG, MediaAction.ACTION_VIDEO)
.putExtra(FILE_PATH_ARG, filePath); .putExtra(FILE_PATH_ARG, filePath);
@ -278,7 +200,22 @@ public class PreviewActivity extends AppCompatActivity implements View.OnClickLi
loadVideoParams(savedInstanceState); loadVideoParams(savedInstanceState);
} }
photoPreviewContainer.setVisibility(View.GONE); photoPreviewContainer.setVisibility(View.GONE);
surfaceView.getHolder().addCallback(surfaceCallbacks); surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
showVideoPreview(holder);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
});
} }
private void showVideoPreview(SurfaceHolder holder) { private void showVideoPreview(SurfaceHolder holder) {
@ -292,7 +229,62 @@ public class PreviewActivity extends AppCompatActivity implements View.OnClickLi
public void onPrepared(MediaPlayer mp) { public void onPrepared(MediaPlayer mp) {
mediaController = new MediaController(PreviewActivity.this); mediaController = new MediaController(PreviewActivity.this);
mediaController.setAnchorView(surfaceView); mediaController.setAnchorView(surfaceView);
mediaController.setMediaPlayer(MediaPlayerControlImpl); mediaController.setMediaPlayer(new MediaController.MediaPlayerControl() {
@Override
public void start() {
mediaPlayer.start();
}
@Override
public void pause() {
mediaPlayer.pause();
}
@Override
public int getDuration() {
return mediaPlayer.getDuration();
}
@Override
public int getCurrentPosition() {
return mediaPlayer.getCurrentPosition();
}
@Override
public void seekTo(int pos) {
mediaPlayer.seekTo(pos);
}
@Override
public boolean isPlaying() {
return mediaPlayer.isPlaying();
}
@Override
public int getBufferPercentage() {
return 0;
}
@Override
public boolean canPause() {
return true;
}
@Override
public boolean canSeekBackward() {
return true;
}
@Override
public boolean canSeekForward() {
return true;
}
@Override
public int getAudioSessionId() {
return mediaPlayer.getAudioSessionId();
}
});
int videoWidth = mp.getVideoWidth(); int videoWidth = mp.getVideoWidth();
int videoHeight = mp.getVideoHeight(); int videoHeight = mp.getVideoHeight();

Loading…
Cancel
Save