├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── MultimediaChanger_1.0.apk ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── developer │ │ └── alienapps │ │ └── multimediachanger │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── developer │ │ │ └── alienapps │ │ │ └── multimediachanger │ │ │ ├── CropActivity.java │ │ │ ├── StartScreen.java │ │ │ ├── StartupScreen.java │ │ │ ├── Utility.java │ │ │ ├── VideoEditor.java │ │ │ └── VideoSliceSeekBar.java │ └── res │ │ ├── drawable │ │ ├── ic_feed_player_current_position.png │ │ └── leftthumb.png │ │ ├── layout │ │ ├── activity_startup_screen.xml │ │ ├── editor_layout.xml │ │ ├── start_layout.xml │ │ └── video_crop_layout.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── developer │ └── alienapps │ └── multimediachanger │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── trimOut_1.mp4 /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | MultimediaChanger -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MultimediaChanger_1.0.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Singhak/MultimediaChanger/351e6702fae4c33d6ed592a2ee1134a9c46a88c1/MultimediaChanger_1.0.apk -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MultimediaChanger 2 | 3 | This is a experimental app which perform basic function 4 | Speed of operation depends on cpu 5 | 6 | I provide one main Feature to merge video and audio by removing existing video sound 7 | 8 | Before merging you can perform extra manupulation on audio i.e you make audio faast or slow. 9 | 10 | Now you caN PERFORM Various operation on video.These operation may take long time its depends on type of video and duration. for example to make video slow or fast it take more time. 11 | 12 | Known issue: 13 | #It may not support some audio and video format since I didnot test for all formats. 14 | #It suppor API level 16 i.e. Jelly_beAN to lolipop I only test on KitKat 4.4. 15 | 16 | ![Demo Video of App](https://github.com/Singhak/MultimediaChanger/blob/master/trimOut_1.mp4) 17 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.developer.alienapps.multimediachanger" 9 | minSdkVersion 16 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.2.1' 26 | compile 'com.writingminds:FFmpegAndroid:0.3.2' 27 | compile 'com.google.android.gms:play-services-appindexing:8.1.0' 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in H:\AndroidStudio\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/developer/alienapps/multimediachanger/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.developer.alienapps.multimediachanger; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 34 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/developer/alienapps/multimediachanger/CropActivity.java: -------------------------------------------------------------------------------- 1 | package com.developer.alienapps.multimediachanger; 2 | 3 | import android.app.Activity; 4 | import android.app.AlertDialog; 5 | import android.app.ProgressDialog; 6 | import android.content.DialogInterface; 7 | import android.media.MediaPlayer; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.os.Environment; 11 | import android.os.Handler; 12 | import android.os.Message; 13 | import android.util.Log; 14 | import android.view.View; 15 | import android.widget.TextView; 16 | import android.widget.VideoView; 17 | 18 | import com.github.hiteshsondhi88.libffmpeg.ExecuteBinaryResponseHandler; 19 | import com.github.hiteshsondhi88.libffmpeg.FFmpeg; 20 | import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException; 21 | 22 | import java.io.File; 23 | import java.io.FileOutputStream; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.io.OutputStream; 27 | 28 | public class CropActivity extends Activity { 29 | 30 | private static final String TAG = CropActivity.class.getSimpleName(); 31 | 32 | TextView textViewLeft, textViewRight; 33 | VideoSliceSeekBar videoSliceSeekBar; 34 | VideoView videoView; 35 | View videoControlBtn; 36 | View videoSabeBtn; 37 | 38 | FFmpeg ffmpeg; 39 | 40 | private ProgressDialog progressDialog; 41 | 42 | @Override 43 | public void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | setContentView(R.layout.video_crop_layout); 46 | textViewLeft = (TextView) findViewById(R.id.left_pointer); 47 | textViewRight = (TextView) findViewById(R.id.right_pointer); 48 | 49 | videoSliceSeekBar = (VideoSliceSeekBar) findViewById(R.id.seek_bar); 50 | videoView = (VideoView) findViewById(R.id.video); 51 | videoControlBtn = findViewById(R.id.video_control_btn); 52 | videoSabeBtn = findViewById(R.id.trimButton); 53 | 54 | progressDialog = new ProgressDialog(this); 55 | progressDialog.setTitle(null); 56 | 57 | initVideoView(); 58 | ffmpeg = FFmpeg.getInstance(this); 59 | } 60 | 61 | 62 | 63 | private void initVideoView() { 64 | videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 65 | @Override 66 | public void onPrepared(final MediaPlayer mp) { 67 | videoSliceSeekBar.setSeekBarChangeListener(new VideoSliceSeekBar.SeekBarChangeListener() { 68 | @Override 69 | public void SeekBarValueChanged(int leftThumb, int rightThumb) { 70 | textViewLeft.setText(getTimeForTrackFormat(leftThumb, true)); 71 | textViewRight.setText(getTimeForTrackFormat(rightThumb, true)); 72 | } 73 | }); 74 | 75 | videoSliceSeekBar.setMaxValue(mp.getDuration()); 76 | videoSliceSeekBar.setLeftProgress(0); 77 | //videoSliceSeekBar.setRightProgress(mp.getDuration()); 78 | videoSliceSeekBar.setRightProgress(10000); //10 segundos como máximo de entrada 79 | videoSliceSeekBar.setProgressMinDiff((5000 * 100)/mp.getDuration()); //Diferencia mínima de 5 segundos 80 | videoSliceSeekBar.setProgressMaxDiff((10000 * 100)/mp.getDuration());//Diferencia máxima de 10 segundos 81 | 82 | videoControlBtn.setOnClickListener(new View.OnClickListener() { 83 | @Override 84 | public void onClick(View v) { 85 | performVideoViewClick(); 86 | } 87 | }); 88 | 89 | videoSabeBtn.setOnClickListener(new View.OnClickListener() { 90 | @Override 91 | public void onClick(View v) { 92 | Log.d(TAG, "Left progress : " + videoSliceSeekBar.getLeftProgress()/1000); 93 | Log.d(TAG, "Right progress : " + videoSliceSeekBar.getRightProgress()/1000); 94 | 95 | Log.d(TAG, "Total Duration : " + mp.getDuration()/1000); 96 | executeTrimCommand(videoSliceSeekBar.getLeftProgress(), videoSliceSeekBar.getRightProgress()); 97 | } 98 | 99 | }); 100 | 101 | } 102 | }); 103 | 104 | videoView.setVideoURI(Uri.parse("and")); 105 | 106 | } 107 | 108 | private void execFFmpegBinary(String cmd) { 109 | String command[] = cmd.split(" "); 110 | FFmpeg fFmpegInstance = FFmpeg.getInstance(this); 111 | try { 112 | 113 | fFmpegInstance.execute(command, new ExecuteBinaryResponseHandler() { 114 | @Override 115 | public void onFailure(String s) { 116 | Log.d(TAG, "FAILED with output : " + s); 117 | } 118 | 119 | @Override 120 | public void onSuccess(String s) { 121 | Log.d(TAG, "SUCCESS with output : " + s); 122 | } 123 | 124 | @Override 125 | public void onProgress(String s) { 126 | Log.d(TAG, "progress : " + s); 127 | } 128 | 129 | @Override 130 | public void onStart() { 131 | progressDialog.setMessage("Processing..."); 132 | progressDialog.show(); 133 | } 134 | 135 | @Override 136 | public void onFinish() { 137 | progressDialog.dismiss(); 138 | } 139 | }); 140 | } catch (FFmpegCommandAlreadyRunningException e) { 141 | // do nothing for now 142 | } 143 | } 144 | 145 | private void performVideoViewClick() { 146 | if (videoView.isPlaying()) { 147 | videoView.pause(); 148 | videoSliceSeekBar.setSliceBlocked(false); 149 | videoSliceSeekBar.removeVideoStatusThumb(); 150 | } else { 151 | videoView.seekTo(videoSliceSeekBar.getLeftProgress()); 152 | videoView.start(); 153 | videoSliceSeekBar.setSliceBlocked(true); 154 | videoSliceSeekBar.videoPlayingProgress(videoSliceSeekBar.getLeftProgress()); 155 | videoStateObserver.startVideoProgressObserving(); 156 | } 157 | } 158 | 159 | public static String getTimeForTrackFormat(int timeInMills, boolean display2DigitsInMinsSection) { 160 | int minutes = (timeInMills / (60 * 1000)); 161 | int seconds = (timeInMills - minutes * 60 * 1000) / 1000; 162 | String result = display2DigitsInMinsSection && minutes < 10 ? "0" : ""; 163 | result += minutes + ":"; 164 | if (seconds < 10) { 165 | result += "0" + seconds; 166 | } else { 167 | result += seconds; 168 | } 169 | return result; 170 | } 171 | 172 | private void showUnsupportedExceptionDialog() { 173 | new AlertDialog.Builder(CropActivity.this) 174 | .setIcon(android.R.drawable.ic_dialog_alert) 175 | .setTitle(getString(R.string.device_not_supported)) 176 | .setMessage(getString(R.string.device_not_supported_message)) 177 | .setCancelable(false) 178 | .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 179 | @Override 180 | public void onClick(DialogInterface dialog, int which) { 181 | CropActivity.this.finish(); 182 | } 183 | }) 184 | .create() 185 | .show(); 186 | 187 | } 188 | 189 | 190 | private StateObserver videoStateObserver = new StateObserver(); 191 | 192 | private class StateObserver extends Handler { 193 | 194 | private boolean alreadyStarted = false; 195 | 196 | private void startVideoProgressObserving() { 197 | if (!alreadyStarted) { 198 | alreadyStarted = true; 199 | sendEmptyMessage(0); 200 | } 201 | } 202 | 203 | private Runnable observerWork = new Runnable() { 204 | @Override 205 | public void run() { 206 | startVideoProgressObserving(); 207 | } 208 | }; 209 | 210 | @Override 211 | public void handleMessage(Message msg) { 212 | alreadyStarted = false; 213 | videoSliceSeekBar.videoPlayingProgress(videoView.getCurrentPosition()); 214 | if (videoView.isPlaying() && videoView.getCurrentPosition() < videoSliceSeekBar.getRightProgress()) { 215 | postDelayed(observerWork, 50); 216 | } else { 217 | 218 | if (videoView.isPlaying()) videoView.pause(); 219 | 220 | videoSliceSeekBar.setSliceBlocked(false); 221 | videoSliceSeekBar.removeVideoStatusThumb(); 222 | } 223 | } 224 | } 225 | 226 | private void executeTrimCommand(int startMs, int endMs) { 227 | File moviesDir = Environment.getExternalStoragePublicDirectory( 228 | Environment.DIRECTORY_MOVIES 229 | ); 230 | 231 | String filePrefix = "make_your_song"; 232 | String fileExtn = ".mp4"; 233 | String fileName = filePrefix + fileExtn; 234 | 235 | try { 236 | InputStream inputStream = getAssets().open(fileName); 237 | File src = new File(moviesDir, fileName); 238 | 239 | storeFile(inputStream, src); 240 | 241 | 242 | File dest = new File(moviesDir, filePrefix + "_1" + fileExtn); 243 | if (dest.exists()) { 244 | dest.delete(); 245 | } 246 | 247 | 248 | Log.d(TAG, "startTrim: src: " + src.getAbsolutePath()); 249 | Log.d(TAG, "startTrim: dest: " + dest.getAbsolutePath()); 250 | Log.d(TAG, "startTrim: startMs: " + startMs); 251 | Log.d(TAG, "startTrim: endMs: " + endMs); 252 | 253 | execFFmpegBinary("-i " + src.getAbsolutePath() + " -ss "+ startMs/1000 + " -to " + endMs/1000 + " -strict -2 -async 1 "+ dest.getAbsolutePath()); 254 | } catch (IOException e) { 255 | e.printStackTrace(); 256 | } catch (Exception e) { 257 | e.printStackTrace(); 258 | } 259 | } 260 | 261 | private void storeFile(InputStream input, File file) { 262 | try { 263 | final OutputStream output = new FileOutputStream(file); 264 | try { 265 | try { 266 | final byte[] buffer = new byte[1024]; 267 | int read; 268 | 269 | while ((read = input.read(buffer)) != -1) 270 | output.write(buffer, 0, read); 271 | 272 | output.flush(); 273 | } finally { 274 | output.close(); 275 | } 276 | } catch (Exception e) { 277 | e.printStackTrace(); 278 | } 279 | } catch (IOException e) { 280 | e.printStackTrace(); 281 | } finally { 282 | try { 283 | input.close(); 284 | } catch (IOException e) { 285 | e.printStackTrace(); 286 | } 287 | } 288 | } 289 | } 290 | -------------------------------------------------------------------------------- /app/src/main/java/com/developer/alienapps/multimediachanger/StartScreen.java: -------------------------------------------------------------------------------- 1 | package com.developer.alienapps.multimediachanger; 2 | 3 | import android.app.Activity; 4 | import android.app.AlertDialog; 5 | import android.content.DialogInterface; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.widget.Button; 10 | 11 | /** 12 | * Created by AMIT on 01-May-16. 13 | */ 14 | public class StartScreen extends Activity { 15 | 16 | Button partAButton, partBButton; 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.start_layout); 21 | partAButton = (Button) findViewById(R.id.part_a); 22 | partBButton = (Button) findViewById(R.id.part_b); 23 | Utility.setupFfmpeg(this); 24 | partAButton.setOnClickListener(new View.OnClickListener() { 25 | @Override 26 | public void onClick(View v) { 27 | Intent intent = new Intent(StartScreen.this, StartupScreen.class); 28 | StartScreen.this.startActivity(intent); 29 | } 30 | }); 31 | 32 | partBButton.setOnClickListener(new View.OnClickListener() { 33 | @Override 34 | public void onClick(View v) { 35 | Intent intent = new Intent(StartScreen.this, VideoEditor.class); 36 | StartScreen.this.startActivity(intent); 37 | } 38 | }); 39 | showMsg(); 40 | 41 | } 42 | 43 | public void showMsg() { 44 | AlertDialog.Builder builder = new AlertDialog.Builder(this); 45 | builder.setTitle("Message"); 46 | builder.setMessage("Time duration of processing depends on length of video, quality of video and type of operation. It also depends on cpu power of mobile. So keep patience"); 47 | builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 48 | @Override 49 | public void onClick(DialogInterface dialog, int which) { 50 | 51 | } 52 | }); 53 | builder.show(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/developer/alienapps/multimediachanger/StartupScreen.java: -------------------------------------------------------------------------------- 1 | package com.developer.alienapps.multimediachanger; 2 | 3 | import android.app.Activity; 4 | import android.app.AlertDialog; 5 | import android.app.ProgressDialog; 6 | import android.content.DialogInterface; 7 | import android.content.Intent; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.os.Message; 12 | import android.os.PowerManager; 13 | import android.support.v7.app.AppCompatActivity; 14 | import android.util.Log; 15 | import android.view.View; 16 | import android.widget.Button; 17 | import android.widget.EditText; 18 | import android.widget.LinearLayout; 19 | import android.widget.Toast; 20 | 21 | import com.github.hiteshsondhi88.libffmpeg.ExecuteBinaryResponseHandler; 22 | import com.github.hiteshsondhi88.libffmpeg.FFmpeg; 23 | import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException; 24 | import com.google.android.gms.appindexing.Action; 25 | import com.google.android.gms.appindexing.AppIndex; 26 | import com.google.android.gms.common.api.GoogleApiClient; 27 | 28 | public class StartupScreen extends AppCompatActivity implements View.OnClickListener { 29 | 30 | private static final String TAG = StartupScreen.class.getSimpleName(); 31 | EditText vbrowseText; 32 | EditText abrowseText; 33 | Button vbrowseButton, trimVideo; 34 | Button abrowseButton, trimAudioButton, slowAudioButton, fastAudioButton; 35 | Button executeButton; 36 | Button folderButton, backButton; 37 | String videopath, audioPath; 38 | String vfinalPath, afinalPath; 39 | String outputPath; 40 | boolean isIntermideate; 41 | private ProgressDialog progressBar; 42 | /** 43 | * ATTENTION: This was auto-generated to implement the App Indexing API. 44 | * See https://g.co/AppIndexing/AndroidStudio for more information. 45 | */ 46 | private GoogleApiClient client; 47 | 48 | private Handler handler = new Handler() { 49 | @Override 50 | public void handleMessage(Message msg) { 51 | if (msg.what == Utility.START_PROGRESS_MSG) { 52 | progressBar.show(); 53 | } else if (msg.what == Utility.STOP_PROGRESS_MSG) { 54 | progressBar.dismiss(); 55 | FFmpeg.getInstance(StartupScreen.this).killRunningProcesses(); 56 | } else if (msg.what == Utility.FFMPEG_FAILURE_MSG) { 57 | progressBar.dismiss(); 58 | msgDialog("There is some problem either in input file or format"); 59 | } else if (msg.what == Utility.FFMPEG_SUCESS_MSG) { 60 | progressBar.dismiss(); 61 | msgDialog("Output file at path : " + outputPath); 62 | } 63 | 64 | } 65 | }; 66 | private String ffLogPath; 67 | 68 | 69 | @Override 70 | protected void onCreate(Bundle savedInstanceState) { 71 | super.onCreate(savedInstanceState); 72 | setContentView(R.layout.activity_startup_screen); 73 | // Utility.setupFfmpeg(this); 74 | initUI(); 75 | 76 | progressBar = new ProgressDialog(StartupScreen.this); 77 | progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER); 78 | progressBar.setTitle("Work in Progress"); 79 | // progressBar.setMessage("Press the cancel button to end the operation"); 80 | // progressBar.setMax(100); 81 | // progressBar.setProgress(0); 82 | 83 | progressBar.setCancelable(false); 84 | progressBar.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { 85 | @Override 86 | public void onClick(DialogInterface dialog, int which) { 87 | handler.sendEmptyMessage(Utility.STOP_PROGRESS_MSG); 88 | } 89 | }); 90 | 91 | // ATTENTION: This was auto-generated to implement the App Indexing API. 92 | // See https://g.co/AppIndexing/AndroidStudio for more information. 93 | client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); 94 | } 95 | 96 | private void initUI() { 97 | vbrowseButton = (Button) findViewById(R.id.vbrowse); 98 | trimVideo = (Button) findViewById(R.id.trim_video); 99 | vbrowseText = (EditText) findViewById(R.id.vpath); 100 | abrowseButton = (Button) findViewById(R.id.abrowse); 101 | trimAudioButton = (Button) findViewById(R.id.trim_audio); 102 | slowAudioButton = (Button) findViewById(R.id.slow_audio); 103 | fastAudioButton = (Button) findViewById(R.id.fast_audio); 104 | abrowseText = (EditText) findViewById(R.id.apath); 105 | executeButton = (Button) findViewById(R.id.run); 106 | folderButton = (Button) findViewById(R.id.outputFolder); 107 | 108 | abrowseButton.setOnClickListener(this); 109 | trimAudioButton.setOnClickListener(this); 110 | vbrowseButton.setOnClickListener(this); 111 | slowAudioButton.setOnClickListener(this); 112 | fastAudioButton.setOnClickListener(this); 113 | trimVideo.setOnClickListener(this); 114 | executeButton.setOnClickListener(this); 115 | folderButton.setOnClickListener(this); 116 | backButton = (Button) findViewById(R.id.backB); 117 | backButton.setOnClickListener(this); 118 | } 119 | 120 | @Override 121 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 122 | if (resultCode == RESULT_OK) { 123 | if (requestCode == Utility.ON_VIDEO_REQUEST) { 124 | Uri selectedImageUri = data.getData(); 125 | vfinalPath = videopath = selectedImageUri.getPath(); 126 | vbrowseText.setText(videopath); 127 | 128 | // String time = Utility.getDuration(videopath, this); 129 | // Toast.makeText(this, time, Toast.LENGTH_LONG).show(); 130 | } else if (requestCode == Utility.ON_AUDIO_REQUEST) { 131 | Uri selectedImageUri = data.getData(); 132 | afinalPath = audioPath = selectedImageUri.getPath(); 133 | abrowseText.setText(audioPath); 134 | } 135 | 136 | } 137 | } 138 | 139 | private void execFFmpegBinary(final String comd) { 140 | String[] command = comd.split(","); 141 | Log.i(TAG, "execFFmpegBinary: " + comd); 142 | FFmpeg fFmpeg = FFmpeg.getInstance(this); 143 | PowerManager powerManager = (PowerManager) this.getSystemService(Activity.POWER_SERVICE); 144 | PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VK_LOCK"); 145 | wakeLock.acquire(); 146 | try { 147 | fFmpeg.execute(command, new ExecuteBinaryResponseHandler() { 148 | @Override 149 | public void onFailure(String s) { 150 | Log.d(TAG, "onFailure: " + s); 151 | // Toast.makeText(StartupScreen.this, "There is some problem inmerging", Toast.LENGTH_LONG).show(); 152 | handler.sendEmptyMessage(Utility.FFMPEG_FAILURE_MSG); 153 | } 154 | 155 | @Override 156 | public void onSuccess(String s) { 157 | Toast.makeText(StartupScreen.this, "Succesfully", Toast.LENGTH_LONG).show(); 158 | if (!isIntermideate) 159 | handler.sendEmptyMessage(Utility.FFMPEG_SUCESS_MSG); 160 | else 161 | progressBar.dismiss(); 162 | } 163 | 164 | @Override 165 | public void onProgress(String s) { 166 | progressBar.setMessage("Processing\n" + s); 167 | } 168 | 169 | @Override 170 | public void onStart() { 171 | handler.sendEmptyMessage(Utility.START_PROGRESS_MSG); 172 | } 173 | 174 | @Override 175 | public void onFinish() { 176 | Log.d(TAG, "Finished command : ffmpeg " + comd); 177 | } 178 | }); 179 | } catch (FFmpegCommandAlreadyRunningException e) { 180 | // do nothing for now 181 | } finally { 182 | wakeLock.release(); 183 | progressBar.dismiss(); 184 | } 185 | } 186 | 187 | public void trimDialog(final int requestId) { 188 | LinearLayout layout = new LinearLayout(this); 189 | layout.setOrientation(LinearLayout.VERTICAL); 190 | 191 | final EditText trimStart = new EditText(this); 192 | trimStart.setHint("Leave it blank = trim from start"); 193 | // trimStart.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL); 194 | layout.addView(trimStart); 195 | 196 | final EditText trimEnd = new EditText(this); 197 | trimEnd.setHint("Leave it blank = trim to end"); 198 | // trimEnd.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL); 199 | layout.addView(trimEnd); 200 | 201 | final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); 202 | alertDialog.setTitle("Enter trim value in seconds"); 203 | alertDialog.setView(layout); 204 | 205 | alertDialog.setPositiveButton("Apply", new DialogInterface.OnClickListener() { 206 | @Override 207 | public void onClick(DialogInterface dialog, int which) { 208 | 209 | if (trimStart.getText().toString().isEmpty() && trimEnd.getText().toString().isEmpty()) { 210 | dialog.cancel(); 211 | } 212 | String startTime = "0"; 213 | String endTime = "0"; 214 | if (requestId == Utility.ON_VIDEO_REQUEST) { 215 | int duration = Utility.getDurationinSec(vfinalPath, StartupScreen.this); 216 | endTime = String.valueOf(duration); 217 | if (!trimStart.getText().toString().isEmpty()) { 218 | startTime = trimStart.getText().toString(); 219 | } 220 | if (!trimEnd.getText().toString().isEmpty()) { 221 | endTime = trimEnd.getText().toString(); 222 | } 223 | String temp = Utility.getOutputPath() + Utility.generateFilename("trimOut") + ".mp4"; 224 | String cmd = String.format(Utility.CLIP_VIDEO_OR_AUDIO, startTime, vfinalPath, endTime, temp); 225 | vfinalPath = temp; 226 | isIntermideate = true; 227 | execFFmpegBinary(cmd); 228 | } else if (requestId == Utility.ON_AUDIO_REQUEST) { 229 | int duration = Utility.getDurationinSec(afinalPath, StartupScreen.this); 230 | endTime = String.valueOf(duration); 231 | if (!trimStart.getText().toString().isEmpty()) { 232 | startTime = trimStart.getText().toString(); 233 | } 234 | if (!trimEnd.getText().toString().isEmpty()) { 235 | endTime = trimEnd.getText().toString(); 236 | } 237 | 238 | String temp = Utility.getOutputPath() + Utility.generateFilename("trimOut") + ".mp3"; 239 | if (Utility.getValidFileNameExth(afinalPath).contains("m4a")) { 240 | temp = Utility.getOutputPath() + Utility.generateFilename("trimOut") + ".aac"; 241 | } 242 | String cmd = String.format(Utility.CLIP_VIDEO_OR_AUDIO, startTime, afinalPath, endTime, temp); 243 | afinalPath = temp; 244 | isIntermideate = true; 245 | execFFmpegBinary(cmd); 246 | } 247 | } 248 | }); 249 | alertDialog.setNegativeButton("Cancle", new DialogInterface.OnClickListener() { 250 | @Override 251 | public void onClick(DialogInterface dialog, int which) { 252 | dialog.cancel(); 253 | } 254 | }); 255 | AlertDialog dialog = alertDialog.create(); 256 | dialog.setCancelable(false); 257 | dialog.setCanceledOnTouchOutside(false); 258 | dialog.show(); 259 | } 260 | 261 | @Override 262 | public void onStart() { 263 | super.onStart(); 264 | 265 | // ATTENTION: This was auto-generated to implement the App Indexing API. 266 | // See https://g.co/AppIndexing/AndroidStudio for more information. 267 | client.connect(); 268 | Action viewAction = Action.newAction( 269 | Action.TYPE_VIEW, // TODO: choose an action type. 270 | "StartupScreen Page", // TODO: Define a title for the content shown. 271 | // TODO: If you have web page content that matches this app activity's content, 272 | // make sure this auto-generated web page URL is correct. 273 | // Otherwise, set the URL to null. 274 | Uri.parse("http://host/path"), 275 | // TODO: Make sure this auto-generated app deep link URI is correct. 276 | Uri.parse("android-app://com.developer.alienapps.multimediachanger/http/host/path") 277 | ); 278 | AppIndex.AppIndexApi.start(client, viewAction); 279 | } 280 | 281 | @Override 282 | public void onStop() { 283 | super.onStop(); 284 | 285 | // ATTENTION: This was auto-generated to implement the App Indexing API. 286 | // See https://g.co/AppIndexing/AndroidStudio for more information. 287 | Action viewAction = Action.newAction( 288 | Action.TYPE_VIEW, // TODO: choose an action type. 289 | "StartupScreen Page", // TODO: Define a title for the content shown. 290 | // TODO: If you have web page content that matches this app activity's content, 291 | // make sure this auto-generated web page URL is correct. 292 | // Otherwise, set the URL to null. 293 | Uri.parse("http://host/path"), 294 | // TODO: Make sure this auto-generated app deep link URI is correct. 295 | Uri.parse("android-app://com.developer.alienapps.multimediachanger/http/host/path") 296 | ); 297 | AppIndex.AppIndexApi.end(client, viewAction); 298 | client.disconnect(); 299 | } 300 | 301 | @Override 302 | public void onClick(View v) { 303 | int id = v.getId(); 304 | switch (id) { 305 | case R.id.trim_audio: { 306 | if (audioPath != null && !audioPath.isEmpty()) { 307 | trimDialog(Utility.ON_AUDIO_REQUEST); 308 | } else { 309 | showMsg("Browse a audio first"); 310 | } 311 | } 312 | break; 313 | case R.id.trim_video: { 314 | if (videopath != null && !videopath.isEmpty()) { 315 | trimDialog(Utility.ON_VIDEO_REQUEST); 316 | } else { 317 | showMsg("Browse a video first"); 318 | } 319 | } 320 | break; 321 | case R.id.run: { 322 | outputPath = Utility.getOutputPath() + Utility.generateFilename(Utility.getValidFileNameFromPath(vfinalPath)) + ".mp4"; 323 | String cmd = String.format(Utility.REMOVE_ADD_AUDIO_TO_VIDEO, vfinalPath, afinalPath, outputPath); 324 | isIntermideate = false; 325 | execFFmpegBinary(cmd); 326 | } 327 | break; 328 | case R.id.abrowse: { 329 | Intent intent = new Intent(); 330 | intent.setType("audio/mp3/m4a/ogg"); 331 | intent.setAction(Intent.ACTION_GET_CONTENT); 332 | this.startActivityForResult(Intent.createChooser(intent, "Select Audio"), Utility.ON_AUDIO_REQUEST); 333 | } 334 | break; 335 | case R.id.vbrowse: { 336 | Intent intent = new Intent(); 337 | intent.setType("video/*"); 338 | intent.setAction(Intent.ACTION_GET_CONTENT); 339 | this.startActivityForResult(Intent.createChooser(intent, "Select Video"), Utility.ON_VIDEO_REQUEST); 340 | } 341 | break; 342 | case R.id.fast_audio: { 343 | isIntermideate = true; 344 | changeAudioSpeed("2.0"); 345 | } 346 | break; 347 | case R.id.slow_audio: { 348 | isIntermideate = true; 349 | changeAudioSpeed("0.5"); 350 | } 351 | break; 352 | case R.id.backB : 353 | { 354 | Intent intent = new Intent(StartupScreen.this, VideoEditor.class); 355 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 356 | StartupScreen.this.startActivity(intent); 357 | } 358 | break; 359 | case R.id.outputFolder: { 360 | String path = Utility.getOutputPath(); 361 | Uri myUri = Uri.parse(path); 362 | Intent intent = new Intent(Intent.ACTION_VIEW); 363 | intent.setDataAndType(myUri, "resource/folder"); 364 | 365 | if (intent.resolveActivityInfo(getPackageManager(), 0) != null) { 366 | startActivity(intent); 367 | } 368 | } 369 | } 370 | } 371 | 372 | private void changeAudioSpeed(String speed) { 373 | String temp = Utility.getOutputPath() + Utility.generateFilename("trimOut") + ".mp3"; 374 | String cmd = String.format(Utility.CHANGE_AUDIO_SPEED, afinalPath, speed, temp); 375 | afinalPath = temp; 376 | execFFmpegBinary(cmd); 377 | } 378 | 379 | public void showMsg(String msg) { 380 | AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); 381 | alertDialogBuilder.setMessage(msg); 382 | final AlertDialog alertDialog = alertDialogBuilder.create(); 383 | alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { 384 | @Override 385 | public void onClick(DialogInterface arg0, int arg1) { 386 | alertDialog.cancel(); 387 | } 388 | }); 389 | 390 | alertDialog.show(); 391 | } 392 | 393 | private void msgDialog(String msg) { 394 | new AlertDialog.Builder(StartupScreen.this) 395 | .setIcon(android.R.drawable.ic_dialog_alert) 396 | .setTitle("Message") 397 | .setMessage(msg) 398 | .setCancelable(false) 399 | .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 400 | @Override 401 | public void onClick(DialogInterface dialog, int which) { 402 | } 403 | }) 404 | .create() 405 | .show(); 406 | 407 | } 408 | } 409 | -------------------------------------------------------------------------------- /app/src/main/java/com/developer/alienapps/multimediachanger/Utility.java: -------------------------------------------------------------------------------- 1 | package com.developer.alienapps.multimediachanger; 2 | 3 | import android.content.Context; 4 | import android.media.MediaPlayer; 5 | import android.net.Uri; 6 | import android.os.Environment; 7 | import android.util.Log; 8 | import android.widget.Toast; 9 | 10 | import com.github.hiteshsondhi88.libffmpeg.FFmpeg; 11 | import com.github.hiteshsondhi88.libffmpeg.LoadBinaryResponseHandler; 12 | import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException; 13 | 14 | import java.io.File; 15 | import java.util.Date; 16 | 17 | /** 18 | * Created by AMIT on 21-Apr-16. 19 | */ 20 | public class Utility { 21 | 22 | final static int ON_VIDEO_REQUEST = 1; 23 | final static int ON_AUDIO_REQUEST = 2; 24 | final static int START_PROGRESS_MSG = 1; 25 | final static int STOP_PROGRESS_MSG = 2; 26 | final static int FFMPEG_SUCESS_MSG = 3; 27 | final static int FFMPEG_FAILURE_MSG = 4; 28 | 29 | public static final String TAG = "Utility"; 30 | public static String REMOVE_SOUND_VIDEO = "-y,-i,%s,-vcodec,copy,-an,%s"; 31 | public static String ADD_SOUND_VIDEO = "-y,-i,%s,-i,%s,-c:v,copy,-c:a,copy,%s"; 32 | public static String EXTRACT_AUDIO_VIDEO = "-y,-i,%s,-vn,%s"; 33 | public static String IMAGE_FROM_VIDEO = "-y,-i,%s,-ss,5,-vframes,1,%s.jpg"; 34 | public static String CLIP_VIDEO_OR_AUDIO = "-y,-ss,%s,-i,%s,-t,%s,-c,copy,%s"; 35 | public static String CHANGE_AUDIO_SPEED = "-y,-i,%s,-filter:a,atempo=%s,%s"; 36 | public static String CHANGE_VIDEO_AUDIO_SPEED = "-y,-i,%s,-filter:a,atempo=2.0,-vn,%s"; 37 | public static String CHANGE_VIDEO_SPEED = "-y,-i,%s,-filter:v,setpts=N/(25*TB),%s"; 38 | public static String REMOVE_ADD_AUDIO_TO_VIDEO = "-y,-i,%s,-i,%s,-c:v,copy,-map,0:v:0,-map,1:a:0,-c:a,copy,%s"; 39 | public static String FLIP_VIDEO = "-y,-i,%s,-vf,vflip,%s"; 40 | public static void setupFfmpeg(Context context) { 41 | FFmpeg ffmpeg = FFmpeg.getInstance(context); 42 | try { 43 | ffmpeg.loadBinary(new LoadBinaryResponseHandler() { 44 | 45 | @Override 46 | public void onStart() {} 47 | 48 | @Override 49 | public void onFailure() {} 50 | 51 | @Override 52 | public void onSuccess() {} 53 | 54 | @Override 55 | public void onFinish() {} 56 | }); 57 | } catch (FFmpegNotSupportedException e) { 58 | // Handle if FFmpeg is not supported by device 59 | Toast.makeText(context,"Your device does not support", Toast.LENGTH_LONG).show(); 60 | } 61 | } 62 | 63 | public static String getDuration(String path, Context context) { 64 | if (!path.isEmpty()) { 65 | MediaPlayer mp = MediaPlayer.create(context, Uri.parse(path)); 66 | if (mp != null) { 67 | int duration = mp.getDuration(); 68 | mp.release(); 69 | return getTimeForTrackFormat(duration); 70 | } 71 | } 72 | return getTimeForTrackFormat(0); 73 | } 74 | 75 | public static int getDurationinSec(String path, Context context) { 76 | if (!path.isEmpty()) { 77 | MediaPlayer mp = MediaPlayer.create(context, Uri.parse(path)); 78 | if (mp != null) { 79 | int duration = mp.getDuration(); 80 | mp.release(); 81 | return duration / 1000; 82 | } 83 | } 84 | return 0; 85 | } 86 | 87 | public static String getOutputPath() { 88 | String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/alien/"; 89 | File dir = new File(path); 90 | try{ 91 | if(dir.mkdir()) { 92 | System.out.println("Directory created"); 93 | } else { 94 | System.out.println("Directory is not created"); 95 | } 96 | }catch(Exception e){ 97 | e.printStackTrace(); 98 | } 99 | return path; 100 | } 101 | 102 | public static String generateFilename(String prifix) { 103 | return prifix +"_"+ String.valueOf(((new Date().getTime())%(1000000000))%1000); 104 | } 105 | 106 | public static String getTimeForTrackFormat(int duration) { 107 | long seconds = duration / 1000; 108 | long minutes = seconds / 60; 109 | long hours = minutes / 60; 110 | long days = hours / 24; 111 | String result = ""; 112 | seconds = seconds % 60; 113 | minutes = minutes % 60; 114 | hours = hours % 24; 115 | if (hours < 10) { 116 | result = "0" + hours + ":"; 117 | } else { 118 | result = hours + ":"; 119 | } 120 | if (minutes < 10) { 121 | result = "0" + minutes + ":"; 122 | } else { 123 | result = minutes + ":"; 124 | } 125 | if (seconds < 10) { 126 | result += "0" + seconds; 127 | } else { 128 | result += seconds; 129 | } 130 | return result; 131 | } 132 | 133 | public static String getValidFileNameFromPath(String path) { 134 | int startIndex = path.lastIndexOf("/") + 1; 135 | int endIndex = path.lastIndexOf("."); 136 | 137 | String name = path.substring(startIndex, endIndex); 138 | String ext = path.substring(endIndex + 1); 139 | Log.d(TAG, "name: " + name + " ext: " + ext); 140 | String validName = (name.replaceAll("\\Q.\\E", "_")).replaceAll(" ", "_"); 141 | Log.d(TAG, "Valid_name: " + validName + " ext: " + ext); 142 | return validName; 143 | } 144 | 145 | public static String getValidFileNameExth(String path) { 146 | int startIndex = path.lastIndexOf("/") + 1; 147 | int endIndex = path.lastIndexOf("."); 148 | 149 | String name = path.substring(startIndex, endIndex); 150 | String ext = path.substring(endIndex + 1); 151 | Log.d(TAG, "name: " + name + " ext: " + ext); 152 | String validName = (name.replaceAll("\\Q.\\E", "_")).replaceAll(" ", "_"); 153 | Log.d(TAG, "Valid_name: " + validName + " ext: " + ext); 154 | return ext; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /app/src/main/java/com/developer/alienapps/multimediachanger/VideoEditor.java: -------------------------------------------------------------------------------- 1 | package com.developer.alienapps.multimediachanger; 2 | 3 | import android.app.Activity; 4 | import android.app.AlertDialog; 5 | import android.app.ProgressDialog; 6 | import android.content.DialogInterface; 7 | import android.content.Intent; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.os.Message; 12 | import android.os.PowerManager; 13 | import android.text.InputType; 14 | import android.util.Log; 15 | import android.view.View; 16 | import android.widget.Button; 17 | import android.widget.EditText; 18 | import android.widget.LinearLayout; 19 | import android.widget.MediaController; 20 | import android.widget.RelativeLayout; 21 | import android.widget.Toast; 22 | import android.widget.VideoView; 23 | 24 | import com.github.hiteshsondhi88.libffmpeg.ExecuteBinaryResponseHandler; 25 | import com.github.hiteshsondhi88.libffmpeg.FFmpeg; 26 | import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException; 27 | 28 | /** 29 | * Created by AMIT on 29-Apr-16. 30 | */ 31 | public class VideoEditor extends Activity implements View.OnClickListener { 32 | 33 | static final String TAG = "VideoEditor"; 34 | Button trimButton, audioSpeedButton, videoSpeedButton; 35 | Button bothSpeedButton, muteButton, extractaudioButton; 36 | Button flipButtonm, extractImageButton, replaceAudi0Button; 37 | Button browseVideoButton, browseAudioButton; 38 | VideoView videoView; 39 | static String videopath, audiopath; 40 | String outputPath; 41 | RelativeLayout relativeLayout; 42 | EditText abrowseText; 43 | ProgressDialog progressBar; 44 | boolean audioReplace = false; 45 | 46 | private Handler handler = new Handler() { 47 | @Override 48 | public void handleMessage(Message msg) { 49 | if (msg.what == Utility.START_PROGRESS_MSG) { 50 | progressBar.show(); 51 | } else if (msg.what == Utility.STOP_PROGRESS_MSG) { 52 | progressBar.dismiss(); 53 | FFmpeg.getInstance(VideoEditor.this).killRunningProcesses(); 54 | } else if (msg.what == Utility.FFMPEG_FAILURE_MSG) { 55 | progressBar.dismiss(); 56 | audioReplace = false; 57 | msgDialog("There is some problem either in input file or format"); 58 | } else if (msg.what == Utility.FFMPEG_SUCESS_MSG) { 59 | progressBar.dismiss(); 60 | audioReplace = false; 61 | msgDialog("Output file at path : " + outputPath); 62 | videoView.suspend(); 63 | playVideo(outputPath); 64 | } 65 | 66 | } 67 | }; 68 | 69 | @Override 70 | protected void onCreate(Bundle savedInstanceState) { 71 | super.onCreate(savedInstanceState); 72 | setContentView(R.layout.editor_layout); 73 | // Utility.setupFfmpeg(this); 74 | progressBar = new ProgressDialog(VideoEditor.this); 75 | progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER); 76 | progressBar.setTitle("Work in Progress"); 77 | progressBar.setCancelable(false); 78 | progressBar.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { 79 | @Override 80 | public void onClick(DialogInterface dialog, int which) { 81 | handler.sendEmptyMessage(Utility.STOP_PROGRESS_MSG); 82 | } 83 | }); 84 | initUI(); 85 | } 86 | 87 | private void initUI() { 88 | trimButton = (Button) findViewById(R.id.trim); 89 | trimButton.setOnClickListener(this); 90 | 91 | audioSpeedButton = (Button) findViewById(R.id.aspeed); 92 | audioSpeedButton.setOnClickListener(this); 93 | 94 | videoSpeedButton = (Button) findViewById(R.id.vspeed); 95 | videoSpeedButton.setOnClickListener(this); 96 | 97 | bothSpeedButton = (Button) findViewById(R.id.backA); 98 | bothSpeedButton.setOnClickListener(this); 99 | 100 | muteButton = (Button) findViewById(R.id.mute); 101 | muteButton.setOnClickListener(this); 102 | 103 | extractImageButton = (Button) findViewById(R.id.get_img); 104 | extractImageButton.setOnClickListener(this); 105 | 106 | extractaudioButton = (Button) findViewById(R.id.get_audio); 107 | extractaudioButton.setOnClickListener(this); 108 | 109 | flipButtonm = (Button) findViewById(R.id.flip); 110 | flipButtonm.setOnClickListener(this); 111 | 112 | replaceAudi0Button = (Button) findViewById(R.id.change_audio); 113 | replaceAudi0Button.setOnClickListener(this); 114 | 115 | browseVideoButton = (Button) findViewById(R.id.vbrowse_video); 116 | browseVideoButton.setOnClickListener(this); 117 | 118 | browseAudioButton = (Button) findViewById(R.id.audio_browse); 119 | browseAudioButton.setOnClickListener(this); 120 | 121 | videoView = (VideoView) findViewById(R.id.videoplayer); 122 | videoView.setMediaController(new MediaController(this)); 123 | 124 | videoView.requestFocus(); 125 | 126 | 127 | relativeLayout = (RelativeLayout) findViewById(R.id.audio_browse_layout); 128 | abrowseText = (EditText) findViewById(R.id.audio_path); 129 | 130 | } 131 | 132 | 133 | @Override 134 | public void onClick(View v) { 135 | int id = v.getId(); 136 | switch (id) { 137 | case R.id.trim: { 138 | if (videopath != null && !videopath.isEmpty()) { 139 | trimDialog(Utility.ON_VIDEO_REQUEST); 140 | } else { 141 | showMsg("Browse a video first"); 142 | } 143 | } 144 | break; 145 | case R.id.vspeed: { 146 | if (videopath != null && !videopath.isEmpty()) { 147 | outputPath = Utility.getOutputPath() + Utility.generateFilename("finalVideo") + ".mp4"; 148 | String cmd = String.format(Utility.CHANGE_VIDEO_SPEED, videopath, outputPath); 149 | execFFmpegBinary(cmd); 150 | } else { 151 | showMsg("Browse a video first"); 152 | } 153 | } 154 | break; 155 | case R.id.aspeed: { 156 | if (videopath != null && !videopath.isEmpty()) { 157 | outputPath = Utility.getOutputPath() + Utility.generateFilename("finalVideo") + ".mp4"; 158 | String cmd = String.format(Utility.CHANGE_VIDEO_AUDIO_SPEED, videopath, outputPath); 159 | execFFmpegBinary(cmd); 160 | } else { 161 | showMsg("Browse a video first"); 162 | } 163 | } 164 | break; 165 | case R.id.backA: { 166 | Intent intent = new Intent(VideoEditor.this, StartupScreen.class); 167 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 168 | startActivity(intent); 169 | } 170 | break; 171 | case R.id.mute: { 172 | if (videopath != null && !videopath.isEmpty()) { 173 | outputPath = Utility.getOutputPath() + Utility.generateFilename("finalVideo") + ".mp4"; 174 | String cmd = String.format(Utility.REMOVE_SOUND_VIDEO, videopath, outputPath); 175 | execFFmpegBinary(cmd); 176 | } else { 177 | showMsg("Browse a video first"); 178 | } 179 | } 180 | break; 181 | case R.id.get_audio: { 182 | if (videopath != null && !videopath.isEmpty()) { 183 | outputPath = Utility.getOutputPath() + Utility.generateFilename("finalVideo") + ".mp3"; 184 | String cmd = String.format(Utility.EXTRACT_AUDIO_VIDEO, videopath, outputPath); 185 | execFFmpegBinary(cmd); 186 | } else { 187 | showMsg("Browse a video first"); 188 | } 189 | } 190 | break; 191 | case R.id.get_img: { 192 | Log.d(TAG, "onClick: getImage :"+id); 193 | Log.d(TAG, "onClick: getImage :"+videopath); 194 | if (videopath != null && !videopath.isEmpty()) { 195 | outputPath = Utility.getOutputPath() + Utility.generateFilename("clipimage"); 196 | String cmd = String.format(Utility.IMAGE_FROM_VIDEO, videopath, outputPath); 197 | Log.d(TAG, "onClick: getImage :"+cmd); 198 | execFFmpegBinary(cmd); 199 | } else { 200 | showMsg("Browse a video first"); 201 | } 202 | } 203 | break; 204 | case R.id.flip: { 205 | if (videopath != null && !videopath.isEmpty()) { 206 | outputPath = Utility.getOutputPath() + Utility.generateFilename("finalVideo") + ".mp4"; 207 | String cmd = String.format(Utility.FLIP_VIDEO, videopath, outputPath); 208 | execFFmpegBinary(cmd); 209 | } else { 210 | showMsg("Browse a video first"); 211 | } 212 | } 213 | break; 214 | case R.id.vbrowse_video: { 215 | Intent intent = new Intent(); 216 | intent.setType("video/*"); 217 | intent.setAction(Intent.ACTION_GET_CONTENT); 218 | this.startActivityForResult(Intent.createChooser(intent, "Select Video"), Utility.ON_VIDEO_REQUEST); 219 | } 220 | break; 221 | case R.id.change_audio: { 222 | audioReplace = true; 223 | relativeLayout.setVisibility(View.VISIBLE); 224 | } 225 | break; 226 | 227 | case R.id.abrowse : 228 | { 229 | Intent intent = new Intent(); 230 | intent.setType("audio/mp3/m4a/ogg"); 231 | intent.setAction(Intent.ACTION_GET_CONTENT); 232 | this.startActivityForResult(Intent.createChooser(intent, "Select Audio"), Utility.ON_AUDIO_REQUEST); 233 | } 234 | } 235 | } 236 | 237 | @Override 238 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 239 | 240 | if (resultCode == RESULT_OK) { 241 | if (requestCode == Utility.ON_VIDEO_REQUEST) { 242 | Uri selectedImageUri = data.getData(); 243 | videopath = selectedImageUri.getPath(); 244 | playVideo(videopath); 245 | // String time = Utility.getDuration(videopath, this); 246 | // Toast.makeText(this, time, Toast.LENGTH_LONG).show(); 247 | if (audioReplace) { 248 | replaceSound(); 249 | } 250 | } else if (requestCode == Utility.ON_AUDIO_REQUEST) { 251 | Uri selectedImageUri = data.getData(); 252 | audiopath = selectedImageUri.getPath(); 253 | abrowseText.setText(audiopath); 254 | if (audioReplace){ 255 | replaceSound(); 256 | } 257 | } 258 | 259 | } 260 | } 261 | 262 | public void replaceSound() { 263 | if (videopath != null && !videopath.isEmpty() && audiopath != null && !audiopath.isEmpty()) { 264 | outputPath = Utility.getOutputPath() + Utility.generateFilename("finalVideo") + ".mp4"; 265 | String cmd = String.format(Utility.REMOVE_ADD_AUDIO_TO_VIDEO, videopath, audiopath, outputPath); 266 | execFFmpegBinary(cmd); 267 | relativeLayout.setVisibility(View.INVISIBLE); 268 | audioReplace = false; 269 | } else { 270 | showMsg("Browse a video and audio to replace"); 271 | } 272 | } 273 | 274 | private void playVideo(String outputPath) { 275 | videoView.setVideoPath(outputPath); 276 | videoView.start(); 277 | } 278 | 279 | public void trimDialog(final int requestId) { 280 | LinearLayout layout = new LinearLayout(this); 281 | layout.setOrientation(LinearLayout.VERTICAL); 282 | 283 | final EditText trimStart = new EditText(this); 284 | trimStart.setHint("Leave it blank = trim from start"); 285 | trimStart.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL); 286 | layout.addView(trimStart); 287 | 288 | final EditText trimEnd = new EditText(this); 289 | trimEnd.setHint("Leave it blank = trim to end"); 290 | trimEnd.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL); 291 | layout.addView(trimEnd); 292 | 293 | final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); 294 | alertDialog.setTitle("Enter trim value in seconds"); 295 | alertDialog.setView(layout); 296 | 297 | alertDialog.setPositiveButton("Apply", new DialogInterface.OnClickListener() { 298 | @Override 299 | public void onClick(DialogInterface dialog, int which) { 300 | 301 | if (trimStart.getText().toString().isEmpty() && trimEnd.getText().toString().isEmpty()) { 302 | dialog.cancel(); 303 | } 304 | String startTime = "0"; 305 | String endTime = "0"; 306 | if (requestId == Utility.ON_VIDEO_REQUEST) { 307 | int duration = Utility.getDurationinSec(videopath, VideoEditor.this); 308 | endTime = String.valueOf(duration); 309 | if (!trimStart.getText().toString().isEmpty()) { 310 | startTime = trimStart.getText().toString(); 311 | } 312 | if (!trimEnd.getText().toString().isEmpty()) { 313 | endTime = trimEnd.getText().toString(); 314 | } 315 | outputPath = Utility.getOutputPath() + Utility.generateFilename("trimOut") + ".mp4"; 316 | String cmd = String.format(Utility.CLIP_VIDEO_OR_AUDIO, videopath, startTime, endTime, outputPath); 317 | // vfinalPath = temp; 318 | execFFmpegBinary(cmd); 319 | } else if (requestId == Utility.ON_AUDIO_REQUEST) { 320 | int duration = Utility.getDurationinSec(audiopath, VideoEditor.this); 321 | endTime = String.valueOf(duration); 322 | if (!trimStart.getText().toString().isEmpty()) { 323 | startTime = trimStart.getText().toString(); 324 | } 325 | if (!trimEnd.getText().toString().isEmpty()) { 326 | endTime = trimEnd.getText().toString(); 327 | } 328 | outputPath = Utility.getOutputPath() + Utility.generateFilename("trimOut") + ".mp3"; 329 | String cmd = String.format(Utility.CLIP_VIDEO_OR_AUDIO, audiopath, startTime, endTime, outputPath); 330 | execFFmpegBinary(cmd); 331 | } 332 | } 333 | }); 334 | alertDialog.setNegativeButton("Cancle", new DialogInterface.OnClickListener() { 335 | @Override 336 | public void onClick(DialogInterface dialog, int which) { 337 | dialog.cancel(); 338 | } 339 | }); 340 | AlertDialog dialog = alertDialog.create(); 341 | dialog.setCancelable(false); 342 | dialog.setCanceledOnTouchOutside(false); 343 | dialog.show(); 344 | // alertDialog.setCancelable(false); 345 | // alertDialog.show(); 346 | } 347 | 348 | private void execFFmpegBinary(final String comd) { 349 | String[] command = comd.split(","); 350 | Log.i(TAG, "execFFmpegBinary: " + comd); 351 | FFmpeg fFmpeg = FFmpeg.getInstance(this); 352 | PowerManager powerManager = (PowerManager) this.getSystemService(Activity.POWER_SERVICE); 353 | PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VK_LOCK"); 354 | wakeLock.acquire(); 355 | try { 356 | fFmpeg.execute(command, new ExecuteBinaryResponseHandler() { 357 | @Override 358 | public void onFailure(String s) { 359 | Log.d(TAG, "onFailure: " + s); 360 | // Toast.makeText(StartupScreen.this, "There is some problem inmerging", Toast.LENGTH_LONG).show(); 361 | handler.sendEmptyMessage(Utility.FFMPEG_FAILURE_MSG); 362 | } 363 | 364 | @Override 365 | public void onSuccess(String s) { 366 | Toast.makeText(VideoEditor.this, "Succesfully", Toast.LENGTH_LONG).show(); 367 | handler.sendEmptyMessage(Utility.FFMPEG_SUCESS_MSG); 368 | } 369 | 370 | @Override 371 | public void onProgress(String s) { 372 | progressBar.setMessage("Processing\n" + s); 373 | } 374 | 375 | @Override 376 | public void onStart() { 377 | handler.sendEmptyMessage(Utility.START_PROGRESS_MSG); 378 | } 379 | 380 | @Override 381 | public void onFinish() { 382 | Log.d(TAG, "Finished command : ffmpeg " + comd); 383 | } 384 | }); 385 | } catch (FFmpegCommandAlreadyRunningException e) { 386 | // do nothing for now 387 | } finally { 388 | wakeLock.release(); 389 | progressBar.dismiss(); 390 | } 391 | } 392 | 393 | public void showMsg(String msg) { 394 | AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); 395 | alertDialogBuilder.setMessage(msg); 396 | final AlertDialog alertDialog = alertDialogBuilder.create(); 397 | alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { 398 | @Override 399 | public void onClick(DialogInterface arg0, int arg1) { 400 | alertDialog.cancel(); 401 | } 402 | }); 403 | 404 | alertDialog.show(); 405 | } 406 | 407 | void showPathDialoge() { 408 | final EditText editText = new EditText(this); 409 | editText.setHint("Enter file name"); 410 | final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); 411 | alertDialog.setTitle("Enter file name"); 412 | alertDialog.setView(editText); 413 | 414 | alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 415 | @Override 416 | public void onClick(DialogInterface dialog, int which) { 417 | if (editText.getText().toString().isEmpty()) { 418 | outputPath = Utility.getOutputPath() + Utility.generateFilename("finalVideo") + ".mp4"; 419 | } else { 420 | outputPath = editText.getText().toString().trim().replace(" ", "_"); 421 | } 422 | } 423 | }); 424 | } 425 | 426 | private void msgDialog(String msg) { 427 | new AlertDialog.Builder(VideoEditor.this) 428 | .setIcon(android.R.drawable.ic_dialog_alert) 429 | .setTitle("Message") 430 | .setMessage(msg) 431 | .setCancelable(false) 432 | .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 433 | @Override 434 | public void onClick(DialogInterface dialog, int which) { 435 | } 436 | }) 437 | .create() 438 | .show(); 439 | 440 | } 441 | } 442 | 443 | -------------------------------------------------------------------------------- /app/src/main/java/com/developer/alienapps/multimediachanger/VideoSliceSeekBar.java: -------------------------------------------------------------------------------- 1 | package com.developer.alienapps.multimediachanger; 2 | 3 | import android.content.Context; 4 | import android.graphics.*; 5 | import android.util.AttributeSet; 6 | import android.util.Log; 7 | import android.view.MotionEvent; 8 | import android.widget.ImageView; 9 | 10 | public class VideoSliceSeekBar extends ImageView { 11 | 12 | private static final String TAG = VideoSliceSeekBar.class.getSimpleName(); 13 | 14 | private static final int SELECT_THUMB_LEFT = 1; 15 | private static final int SELECT_THUMB_RIGHT = 2; 16 | private static final int SELECT_THUMB_NON = 0; 17 | 18 | 19 | //params 20 | private Bitmap thumbSlice = BitmapFactory.decodeResource(getResources(), R.drawable.ic_feed_player_current_position); 21 | private Bitmap thumbCurrentVideoPosition = BitmapFactory.decodeResource(getResources(), R.drawable.leftthumb); 22 | private int progressMinDiff = 15; //percentage 23 | private int progressMaxDiff = 100; //percentage 24 | private int progressColor = getResources().getColor(R.color.blue); 25 | private int secondaryProgressColor = getResources().getColor(R.color.blue_light); 26 | private int progressHalfHeight = 3; 27 | private int thumbPadding = getResources().getDimensionPixelOffset(R.dimen.default_margin); 28 | private int maxValue = 100; 29 | 30 | 31 | private int progressMinDiffPixels; 32 | private int progressMaxDiffPixels; 33 | private int thumbSliceLeftX, thumbSliceRightX, thumbCurrentVideoPositionX; 34 | private int thumbSliceLeftValue, thumbSliceRightValue; 35 | private int thumbSliceY, thumbCurrentVideoPositionY; 36 | private Paint paint = new Paint(); 37 | private Paint paintThumb = new Paint(); 38 | private int selectedThumb; 39 | private int thumbSliceHalfWidth, thumbCurrentVideoPositionHalfWidth; 40 | private SeekBarChangeListener scl; 41 | 42 | private int progressTop; 43 | private int progressBottom; 44 | 45 | private boolean blocked; 46 | private boolean isVideoStatusDisplay; 47 | 48 | public VideoSliceSeekBar(Context context, AttributeSet attrs, int defStyle) { 49 | super(context, attrs, defStyle); 50 | } 51 | 52 | public VideoSliceSeekBar(Context context, AttributeSet attrs) { 53 | super(context, attrs); 54 | } 55 | 56 | public VideoSliceSeekBar(Context context) { 57 | super(context); 58 | } 59 | 60 | @Override 61 | public void onWindowFocusChanged(boolean hasWindowFocus) { 62 | super.onWindowFocusChanged(hasWindowFocus); 63 | init(); 64 | } 65 | 66 | private void init() { 67 | if (thumbSlice.getHeight() > getHeight()) 68 | getLayoutParams().height = thumbSlice.getHeight(); 69 | 70 | thumbSliceY = (getHeight() / 2) - (thumbSlice.getHeight() / 2); 71 | thumbCurrentVideoPositionY = (getHeight() / 2) - (thumbCurrentVideoPosition.getHeight() / 2); 72 | 73 | thumbSliceHalfWidth = thumbSlice.getWidth() / 2; 74 | thumbCurrentVideoPositionHalfWidth = thumbCurrentVideoPosition.getWidth() / 2; 75 | if (thumbSliceLeftX == 0 || thumbSliceRightX == 0) { 76 | thumbSliceLeftX = thumbPadding; 77 | thumbSliceRightX = getWidth() - thumbPadding; 78 | } 79 | progressMinDiffPixels = calculateCorrds(progressMinDiff) - 2 * thumbPadding; 80 | progressMaxDiffPixels = calculateCorrds(progressMaxDiff) - 2 * thumbPadding; 81 | progressTop = getHeight() / 2 - progressHalfHeight; 82 | progressBottom = getHeight() / 2 + progressHalfHeight; 83 | invalidate(); 84 | } 85 | 86 | public void setSeekBarChangeListener(SeekBarChangeListener scl) { 87 | this.scl = scl; 88 | } 89 | 90 | @Override 91 | protected void onDraw(Canvas canvas) { 92 | super.onDraw(canvas); 93 | Rect rect; 94 | //generate and draw progress 95 | paint.setColor(progressColor); 96 | rect = new Rect(thumbPadding, progressTop, thumbSliceLeftX, progressBottom); 97 | canvas.drawRect(rect, paint); 98 | rect = new Rect(thumbSliceRightX, progressTop, getWidth() - thumbPadding, progressBottom); 99 | canvas.drawRect(rect, paint); 100 | 101 | //generate and draw secondary progress 102 | paint.setColor(secondaryProgressColor); 103 | rect = new Rect(thumbSliceLeftX, progressTop, thumbSliceRightX, progressBottom); 104 | canvas.drawRect(rect, paint); 105 | 106 | if (!blocked) { 107 | //generate and draw thumbs pointer 108 | canvas.drawBitmap(thumbSlice, thumbSliceLeftX - thumbSliceHalfWidth, thumbSliceY, paintThumb); 109 | canvas.drawBitmap(thumbSlice, thumbSliceRightX - thumbSliceHalfWidth, thumbSliceY, paintThumb); 110 | } 111 | if (isVideoStatusDisplay) { 112 | //generate and draw video thump pointer 113 | canvas.drawBitmap(thumbCurrentVideoPosition, thumbCurrentVideoPositionX - thumbCurrentVideoPositionHalfWidth, 114 | thumbCurrentVideoPositionY, paintThumb); 115 | } 116 | } 117 | 118 | @Override 119 | public boolean onTouchEvent(MotionEvent event) { 120 | if (!blocked) { 121 | int mx = (int) event.getX(); 122 | switch (event.getAction()) { 123 | case MotionEvent.ACTION_DOWN: 124 | if (mx >= thumbSliceLeftX - thumbSliceHalfWidth 125 | && mx <= thumbSliceLeftX + thumbSliceHalfWidth || mx < thumbSliceLeftX - thumbSliceHalfWidth) { 126 | selectedThumb = SELECT_THUMB_LEFT; 127 | } else if (mx >= thumbSliceRightX - thumbSliceHalfWidth 128 | && mx <= thumbSliceRightX + thumbSliceHalfWidth || mx > thumbSliceRightX + thumbSliceHalfWidth) { 129 | selectedThumb = SELECT_THUMB_RIGHT; 130 | } else if (mx - thumbSliceLeftX + thumbSliceHalfWidth < thumbSliceRightX - thumbSliceHalfWidth - mx) { 131 | selectedThumb = SELECT_THUMB_LEFT; 132 | } else if (mx - thumbSliceLeftX + thumbSliceHalfWidth > thumbSliceRightX - thumbSliceHalfWidth - mx) { 133 | selectedThumb = SELECT_THUMB_RIGHT; 134 | } 135 | break; 136 | case MotionEvent.ACTION_MOVE: 137 | if ((mx <= thumbSliceLeftX + thumbSliceHalfWidth + progressMinDiffPixels && selectedThumb == SELECT_THUMB_RIGHT) || 138 | (mx >= thumbSliceRightX - thumbSliceHalfWidth - progressMinDiffPixels && selectedThumb == SELECT_THUMB_LEFT)) { 139 | selectedThumb = SELECT_THUMB_NON; 140 | } 141 | 142 | if ((mx >= thumbSliceLeftX + thumbSliceHalfWidth + progressMaxDiffPixels && selectedThumb == SELECT_THUMB_RIGHT) || 143 | (mx <= thumbSliceRightX - thumbSliceHalfWidth - progressMaxDiffPixels && selectedThumb == SELECT_THUMB_LEFT)) { 144 | selectedThumb = SELECT_THUMB_NON; 145 | } 146 | 147 | if (selectedThumb == SELECT_THUMB_LEFT) { 148 | thumbSliceLeftX = mx; 149 | } else if (selectedThumb == SELECT_THUMB_RIGHT) { 150 | thumbSliceRightX = mx; 151 | } 152 | break; 153 | case MotionEvent.ACTION_UP: 154 | selectedThumb = SELECT_THUMB_NON; 155 | break; 156 | } 157 | notifySeekBarValueChanged(); 158 | } 159 | return true; 160 | } 161 | 162 | private void notifySeekBarValueChanged() { 163 | if (thumbSliceLeftX < thumbPadding) 164 | thumbSliceLeftX = thumbPadding; 165 | 166 | if (thumbSliceRightX < thumbPadding) 167 | thumbSliceRightX = thumbPadding; 168 | 169 | if (thumbSliceLeftX > getWidth() - thumbPadding) 170 | thumbSliceLeftX = getWidth() - thumbPadding; 171 | 172 | if (thumbSliceRightX > getWidth() - thumbPadding) 173 | thumbSliceRightX = getWidth() - thumbPadding; 174 | 175 | invalidate(); 176 | if (scl != null) { 177 | calculateThumbValue(); 178 | scl.SeekBarValueChanged(thumbSliceLeftValue, thumbSliceRightValue); 179 | } 180 | } 181 | 182 | private void calculateThumbValue() { 183 | thumbSliceLeftValue = (maxValue * (thumbSliceLeftX - thumbPadding)) / (getWidth() - 2 * thumbPadding); 184 | thumbSliceRightValue = (maxValue * (thumbSliceRightX - thumbPadding)) / (getWidth() - 2 * thumbPadding); 185 | } 186 | 187 | 188 | private int calculateCorrds(int progress) { 189 | int width = getWidth(); 190 | return (int) (((width - 2d * thumbPadding) / maxValue) * progress) + thumbPadding; 191 | } 192 | 193 | public void setLeftProgress(int progress) { 194 | if (progress < thumbSliceRightValue - progressMinDiff 195 | && progress > thumbSliceRightValue - progressMaxDiff) { 196 | thumbSliceLeftX = calculateCorrds(progress); 197 | } 198 | notifySeekBarValueChanged(); 199 | } 200 | 201 | public void setRightProgress(int progress) { 202 | Log.d("VideoSliceSeekBar : ", "" + progress); 203 | if (progress > thumbSliceLeftValue + progressMinDiff) { 204 | Log.d("VideoSliceSeekBar : ", "Actualizo slice Right: " + (thumbSliceLeftValue + progressMaxDiff)); 205 | thumbSliceRightX = calculateCorrds(progress); 206 | } 207 | notifySeekBarValueChanged(); 208 | } 209 | 210 | public int getLeftProgress() { 211 | return thumbSliceLeftValue; 212 | } 213 | 214 | public int getRightProgress() { 215 | return thumbSliceRightValue; 216 | } 217 | 218 | public void setProgress(int leftProgress, int rightProgress) { 219 | if (rightProgress - leftProgress > progressMinDiff) { 220 | thumbSliceLeftX = calculateCorrds(leftProgress); 221 | thumbSliceRightX = calculateCorrds(rightProgress); 222 | } 223 | notifySeekBarValueChanged(); 224 | } 225 | 226 | public void videoPlayingProgress(int progress) { 227 | isVideoStatusDisplay = true; 228 | thumbCurrentVideoPositionX = calculateCorrds(progress); 229 | invalidate(); 230 | } 231 | 232 | public void removeVideoStatusThumb() { 233 | isVideoStatusDisplay = false; 234 | invalidate(); 235 | } 236 | 237 | public void setSliceBlocked(boolean isBLock) { 238 | blocked = isBLock; 239 | invalidate(); 240 | } 241 | 242 | public void setMaxValue(int maxValue) { 243 | this.maxValue = maxValue; 244 | } 245 | 246 | public void setProgressMinDiff(int progressMinDiff) { 247 | this.progressMinDiff = progressMinDiff; 248 | progressMinDiffPixels = calculateCorrds((progressMinDiff/100) * maxValue); 249 | } 250 | 251 | public void setProgressMaxDiff(int progressMaxDiff) { 252 | this.progressMaxDiff = progressMaxDiff; 253 | int progressTotal = (progressMaxDiff * maxValue) / 100; 254 | progressMaxDiffPixels = calculateCorrds(progressTotal); 255 | } 256 | 257 | public void setProgressHeight(int progressHeight) { 258 | this.progressHalfHeight = progressHalfHeight / 2; 259 | invalidate(); 260 | } 261 | 262 | public void setProgressColor(int progressColor) { 263 | this.progressColor = progressColor; 264 | invalidate(); 265 | } 266 | 267 | public void setSecondaryProgressColor(int secondaryProgressColor) { 268 | this.secondaryProgressColor = secondaryProgressColor; 269 | invalidate(); 270 | } 271 | 272 | public void setThumbSlice(Bitmap thumbSlice) { 273 | this.thumbSlice = thumbSlice; 274 | init(); 275 | } 276 | 277 | public void setThumbCurrentVideoPosition(Bitmap thumbCurrentVideoPosition) { 278 | this.thumbCurrentVideoPosition = thumbCurrentVideoPosition; 279 | init(); 280 | } 281 | 282 | public void setThumbPadding(int thumbPadding) { 283 | this.thumbPadding = thumbPadding; 284 | invalidate(); 285 | } 286 | 287 | public interface SeekBarChangeListener { 288 | void SeekBarValueChanged(int leftThumb, int rightThumb); 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_feed_player_current_position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Singhak/MultimediaChanger/351e6702fae4c33d6ed592a2ee1134a9c46a88c1/app/src/main/res/drawable/ic_feed_player_current_position.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/leftthumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Singhak/MultimediaChanger/351e6702fae4c33d6ed592a2ee1134a9c46a88c1/app/src/main/res/drawable/leftthumb.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_startup_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 21 | 22 |