diff --git a/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java b/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java index 96adc0b..b11812a 100644 --- a/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.java +++ b/app/src/main/java/com/github/florent37/camerafragment/sample/MainActivity.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(){ final CameraFragmentApi cameraFragment = getCameraFragment(); if (cameraFragment != null) { diff --git a/art/default_camera.png b/art/default_camera.png deleted file mode 100644 index e107f70..0000000 Binary files a/art/default_camera.png and /dev/null differ diff --git a/art/settings_for_video_limitation.png b/art/settings_for_video_limitation.png deleted file mode 100644 index 4e01890..0000000 Binary files a/art/settings_for_video_limitation.png and /dev/null differ diff --git a/art/video_camera.png b/art/video_camera.png deleted file mode 100644 index 63e3a06..0000000 Binary files a/art/video_camera.png and /dev/null differ diff --git a/art/video_low_quality.png b/art/video_low_quality.png deleted file mode 100644 index 1b58f69..0000000 Binary files a/art/video_low_quality.png and /dev/null differ diff --git a/camerafragment/src/main/java/com/github/florent37/camerafragment/PreviewActivity.java b/camerafragment/src/main/java/com/github/florent37/camerafragment/PreviewActivity.java index d343d97..241f0e6 100644 --- a/camerafragment/src/main/java/com/github/florent37/camerafragment/PreviewActivity.java +++ b/camerafragment/src/main/java/com/github/florent37/camerafragment/PreviewActivity.java @@ -67,91 +67,13 @@ public class PreviewActivity extends AppCompatActivity implements View.OnClickLi private float[] ratios; private String[] ratioLabels; - private SurfaceHolder.Callback surfaceCallbacks = 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 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) { - + public static Intent newIntentPhoto(Context context, String filePath) { return new Intent(context, PreviewActivity.class) .putExtra(MEDIA_ACTION_ARG, MediaAction.ACTION_PHOTO) .putExtra(FILE_PATH_ARG, filePath); } - public static Intent newIntentVideo(Context context, - String filePath) { - + public static Intent newIntentVideo(Context context, String filePath) { return new Intent(context, PreviewActivity.class) .putExtra(MEDIA_ACTION_ARG, MediaAction.ACTION_VIDEO) .putExtra(FILE_PATH_ARG, filePath); @@ -278,7 +200,22 @@ public class PreviewActivity extends AppCompatActivity implements View.OnClickLi loadVideoParams(savedInstanceState); } 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) { @@ -292,7 +229,62 @@ public class PreviewActivity extends AppCompatActivity implements View.OnClickLi public void onPrepared(MediaPlayer mp) { mediaController = new MediaController(PreviewActivity.this); 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 videoHeight = mp.getVideoHeight();