Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmedbadereldin committed Aug 9, 2020
1 parent 24345c3 commit 503ef05
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 22 deletions.
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,50 @@
# Video-Trimmer-Android
Trim the video by adjusting starting point and ending point in Android.
# Video-Trimmer-Android #
Trim the video by adjusting starting point and ending point in Android.


<a target="_blank" href="LICENSE"><img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg" alt="license : MIT"></a>
<a target="_blank" href="https://www.cmarix.com/android-application-development-services.html"><img src="https://img.shields.io/badge/platform-android-blue.svg" alt="license : MIT"></a>

## Core Features ##

- Video can be trimmed/shortened and played on the same screen
- Video can be trimmed by selecting the starting point and ending point, and it will display the video size and video duration based on the selected position
- Seekbar moves as per selected video for trimming
- You can specify the length of the video before cut.

## How it works ##

- User can record video from camera or select video from gallery
- Set the selected video in the trimming screen
- Trim the video by dragging starting point and end point
- View trimmed video on the trimming screen
- Save video, it will show image from video in next screen.
- You can use the video after that as you like, like upload to server.

## Purpose of this code ##

- Whenever it is required to crop thr video, this code can help you
- Whenever you are having a limiation of video recording such as allow users to record video for 1 min, this code can help you


## Requirements ##

- Android 4.1+


## Contact me via e-mail ##
For any inquiries or clarifications, you can contact me via e-mail. Just send an email to [[email protected]](mailto:[email protected] "[email protected]").

## Contact me via social media ##

[Facebook](https://www.facebook.com/AhmedMBaderElDin) | [Twitter](https://twitter.com/AhmedBaderEDin) | [Linkedin](https://www.linkedin.com/in/ahmed-m-bader-el-din-0ba48bb5/)

## Libraries ##

- [SDP - a scalable size unit](https://github.com/intuit/sdp)
- [SSP - a scalable size unit for texts](https://github.com/intuit/ssp)
- [Android RunTime Permission](https://github.com/fccaikai/AndroidPermissionX)
- [read, write and create MP4 files](https://github.com/sannies/mp4parser)
- [Pick image or video](https://github.com/iamthevoid/media-picker-android)
- [View images](https://github.com/bumptech/glide)

8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'

implementation 'com.googlecode.mp4parser:isoparser:1.1.22'
implementation 'com.github.danylovolokh:video-player-manager:0.2.0'
implementation 'com.github.fccaikai:AndroidPermissionX:1.0.0'

implementation 'com.googlecode.mp4parser:isoparser:1.1.22'

implementation 'iam.void.mediapicker:mediapicker:0.2.3'
implementation 'io.reactivex:rxjava:1.3.5'
implementation 'io.reactivex:rxandroid:1.2.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.ahmedbadereldin.videotrimmerapplication.R;
import com.bumptech.glide.Glide;
import com.kcode.permissionslib.main.OnRequestPermissionsCallBack;
import com.kcode.permissionslib.main.PermissionCompat;

import java.io.File;
import java.util.Objects;

import iam.thevoid.mediapicker.rxmediapicker.Purpose;
import iam.thevoid.mediapicker.rxmediapicker.RxMediaPicker;
import rx.functions.Action1;


public class NewPostActivity extends AppCompatActivity {

private EditText contentTxt;
private ImageView videoBtn;
private FrameLayout postImgLY;
private ImageView postImg;
Expand Down Expand Up @@ -64,7 +67,6 @@ protected void onNewIntent(Intent intent) {
}

private void initViews() {
contentTxt = findViewById(R.id.contentTxt);
videoBtn = findViewById(R.id.videoBtn);
postImgLY = findViewById(R.id.postImgLY);
postImg = findViewById(R.id.postImg);
Expand All @@ -80,11 +82,8 @@ private void setSharedInentData(Intent sharedInentData) {
if (receivedAction != null && receivedAction.equals(Intent.ACTION_SEND)) {
//content is being shared

if (receivedType.startsWith("text/")) {
//handle sent text
String receivedText = sharedInentData.getStringExtra(Intent.EXTRA_TEXT);
contentTxt.setText(receivedText);
} else if (receivedType.startsWith("image/")) {
assert receivedType != null;
if (receivedType.startsWith("image/")) {
//handle sent image
uriPostImg = sharedInentData.getParcelableExtra(Intent.EXTRA_STREAM);
if (uriPostImg != null) {
Expand Down Expand Up @@ -159,13 +158,10 @@ public void onDenied(String permission) {
}

private void loadIage(Uri filepath) {
Log.d("loadIage", "loadIage: " + filepath);

// MEDIA GALLERY
String path = getPath(filepath);
Uri filea = Uri.fromFile(new File(path));
String fileExt = MimeTypeMap.getFileExtensionFromUrl(filea.toString());
Log.d("onActivityResultaaa", "onActivityResult: " + fileExt);

if (fileExt.equalsIgnoreCase("MP4")) {
File file = new File(path);
Expand Down
9 changes: 3 additions & 6 deletions app/src/main/res/layout/activity_new_post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
android:layout_height="match_parent"
android:orientation="vertical">


<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
Expand All @@ -27,7 +26,8 @@
android:inputType="textMultiLine"
android:paddingTop="@dimen/_5sdp"
android:paddingBottom="@dimen/_5sdp"
android:textColor="@color/app_blue"/>
android:textColor="@color/app_blue"
android:visibility="invisible" />

<FrameLayout
android:id="@+id/postImgLY"
Expand Down Expand Up @@ -66,7 +66,7 @@
<ImageView
android:id="@+id/videoBtn"
android:layout_width="0dp"
android:layout_height="@dimen/_24sdp"
android:layout_height="@dimen/_49sdp"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/ic_baseline_videocam_24a" />
Expand All @@ -77,9 +77,6 @@
</LinearLayout>




</FrameLayout>


</LinearLayout>

0 comments on commit 503ef05

Please sign in to comment.