hluhovskyi / camerabutton Goto Github PK
View Code? Open in Web Editor NEWInstagram-like button for taking photos or recording videos
License: Apache License 2.0
Instagram-like button for taking photos or recording videos
License: Apache License 2.0
Hi, i am using this library. I have one question regarding the one property of the button.
I want toset Expanded stroke width, in the current demo i am not able to use this property.
Please can you explain me or can you give me any demo, how to use below property? I want to minimize the Expanded stroke width.
stroke_width_expanded = min(layout_width, layout_height) - main_circle_expanded
https://github.com/hluhovskyi/CameraButton/blob/master/.github/arts/cb_stroke_width_expanded.png
Hi getting the following error.
com.dewarder.camerabutton.CameraButton.postExpandingMessageIfNeeded
I enjoy your button. But i need to cancel video recording when user release button earlier MAX_HOLD_DURATION.
But onCancel event not called.
`cameraButton = findViewById(R.id.camera_button);
cameraButton.setMode(CameraButton.Mode.HOLD);
cameraButton.setHoldDuration(MAX_DURATION);
cameraButton.setProgressArcColors(new int[]{getResources().getColor(R.color.lightblue),
getResources().getColor(R.color.lightblue)});
camera.addCameraListener(new CameraListener() {
@OverRide
public void onVideoTaken(File video) {
if (videoTaken) {
Intent intent = new Intent();
intent.putExtra("videoSelfie", video.getAbsolutePath());
setResult(RESULT_OK, intent);
finish();
}
}
});
cameraButton.setOnHoldEventListener(new CameraButton.OnHoldEventListener() {
@OverRide
public void onStart() {
camera.startCapturingVideo(null, MAX_DURATION);
}
@Override
public void onFinish() {
videoTaken = true;
camera.stopCapturingVideo();
}
@Override
public void onCancel() {
camera.stopCapturingVideo();
Toast.makeText(CameraActivity.this, R.string.selfie_error, Toast.LENGTH_SHORT).show();
}
});`
Thank you for this awesome library!
I'm having an issue where I'm trying to record a 15 second video however, it seems as if the recording time of the button and cameraview are not in sync.
If I set the button duration to 15000, it only records 4 seconds of video but if I set it to 38000, it records 15 seconds. There is an issue with that also, if I set the duration to 38000, and let go of the button the onCancel method should be called and stop the video at whatever interval it was at (for arguments sake lets say 5 seconds), but this is not the case, it instead stops at less than a second.
On the other hand, if I set the cameraview record duration to 15000, the same thing happens, it records 4 seconds of video and if I let go of the button early it only records less than a second.
cameraButton.setVideoDuration(38000);
cameraButton.setOnVideoEventListener(new CameraButton.OnVideoEventListener() {
@Override
public void onStart() {
cameraView.setSessionType(SessionType.VIDEO);
if (mCapturingPicture || mCapturingVideo)
mCapturingVideo = true;
flashSwitchView.setVisibility(View.GONE);
gallery.setVisibility(View.GONE);
File path = new File(Environment.getExternalStorageDirectory() + "/Pictematic/Media/Pictematic Video");
File file = new File(path, "VID-" + System.currentTimeMillis() + ".mp4");
cameraView.startCapturingVideo(file);
}
@Override
public void onFinish() {
flashSwitchView.setVisibility(View.VISIBLE);
gallery.setVisibility(View.VISIBLE);
cameraView.stopCapturingVideo(); //works fine and saves the entire 15 seconds video if I let the button progress complete
}
@Override
public void onCancel() {
flashSwitchView.setVisibility(View.VISIBLE);
gallery.setVisibility(View.VISIBLE);
cameraView.stopCapturingVideo(); //Should save the video at whatever interval the button was released
}
});
XML snippet
<com.otaliastudios.cameraview.CameraView
android:id="@+id/cameraView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cameraGrid="off"
app:cameraCropOutput="false"
app:cameraFacing="back"
app:cameraFlash="off"
app:cameraGestureTap="focusWithMarker"
app:cameraGestureLongTap="none"
app:cameraGesturePinch="zoom"
app:cameraGestureScrollHorizontal="exposureCorrection"
app:cameraGestureScrollVertical="none"
app:cameraJpegQuality="100"
app:cameraVideoQuality="highest"/>
<com.hluhovskyi.camerabutton.CameraButton
android:id="@+id/camera_button"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"
android:layout_width="@dimen/cb_layout_width_default"
android:layout_height="@dimen/cb_layout_height_default" />
Hi, i have used your library , but in my code CameraButton is not showing in screen,i will post my code.
in console i am getting
V/CameraButton: dispatchStateChange PRESSED -> DEFAULT
Activity.java code is
package com.tether.activity;
public class AddPostActivity extends BaseActivity implements View.OnClickListener {
CameraButton cameraButton;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findViewById(R.id.btn_image_sample).setOnClickListener(this);
findViewById(R.id.btn_camera_sample).setOnClickListener(this);
findViewById(R.id.btn_video_filters_sample).setOnClickListener(this);
}
@Override
protected int getLayoutResID() {
return R.layout.add_post_layout;
}
@Override
protected void initUI() {
cameraButton = findViewById(R.id.camera_button);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_chat_active);
cameraButton.setIcons(new Bitmap[]{bm});
/*cameraButton.setIcons(new Bitmap[]{
BitmapHelper.getBitmap(this, R.drawable.ic_casino_28dp)});*/
}
@Override
protected void initListeners() {
cameraButton.setOnVideoEventListener(new CameraButton.OnVideoEventListener() {
@Override
public void onStart() {
Log.e("onStart","onStart");
}
@Override
public void onFinish() {
Log.e("onFinish","onFinish");
}
@Override
public void onCancel() {
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/btn_image_sample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Image Sample" />
<Button
android:id="@+id/btn_camera_sample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Camera Sample" />
<Button
android:id="@+id/btn_video_filters_sample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Video Filters Sample" />
<com.hluhovskyi.camerabutton.CameraButton
android:id="@+id/camera_button"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="24dp"
app:cb_collapse_action="click"
app:cb_collapse_duration="10" />
</LinearLayout>
</LinearLayout>
I'm using version 2.0.1
I wonder how to set progress to 0 and record a new video if user still press the button
Pixeled icons how to fix
Could you please allow to animate/set state of the button programatically, so that we can emulate the Hold/Release and progress animations programatically too.
We use single tap for recording video and single tap again to stop recording instead of LongPress So currently there is no way to show progress and animation via Single Tap.
Hi @hluhovskyi , congratulations on the module can I ask you some questions?
For example, could you publish an apk to test the example without having to download the trial project?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.