react-native-video-trim 2.2.5 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -327,8 +327,10 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
327
327
  }
328
328
 
329
329
  private void mediaCompleted() {
330
- setPlayPauseViewIcon(false);
331
- mTimingHandler.removeCallbacks(mTimingRunnable);
330
+ onMediaPause();
331
+
332
+ // when mediaCompleted is called, the endTime may not be exactly at the end of the video (can be slightly before), therefore we should seek to exact position on ended
333
+ seekTo(endTime, true);
332
334
  }
333
335
 
334
336
  private void playOrPause() {
@@ -345,11 +347,9 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
345
347
  }
346
348
 
347
349
  public void onMediaPause() {
348
- if (mediaPlayer.isPlaying()) {
349
- mTimingHandler.removeCallbacks(mTimingRunnable);
350
- mediaPlayer.pause();
351
- setPlayPauseViewIcon(false);
352
- }
350
+ mTimingHandler.removeCallbacks(mTimingRunnable);
351
+ mediaPlayer.pause();
352
+ setPlayPauseViewIcon(false);
353
353
  }
354
354
 
355
355
  public void setOnTrimVideoListener(VideoTrimListener onTrimVideoListener) {
@@ -521,27 +521,13 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
521
521
  mTimingRunnable = new Runnable() {
522
522
  @Override
523
523
  public void run() {
524
- // prevent crashing when video is playing and we close editor
525
524
  try {
526
- if (mediaPlayer == null || !mediaPlayer.isPlaying()) {
527
- mTimingHandler.removeCallbacks(mTimingRunnable);
528
- return;
529
- }
525
+ updateCurrentTime(true);
526
+ mTimingHandler.postDelayed(this, TIMING_UPDATE_INTERVAL);
530
527
  } catch (IllegalStateException e) {
531
528
  e.printStackTrace();
532
529
  mTimingHandler.removeCallbacks(mTimingRunnable);
533
- Log.d(TAG, "startTimingRunnable mediaPlayer is already released");
534
- return;
535
- }
536
-
537
- int currentPosition = mediaPlayer.getCurrentPosition();
538
-
539
- if (currentPosition >= endTime) {
540
- onMediaPause();
541
- seekTo(endTime, true); // Ensure exact end time display
542
- } else {
543
- updateCurrentTime(true);
544
- mTimingHandler.postDelayed(this, TIMING_UPDATE_INTERVAL);
530
+ // this is to catch the error thrown if we close editor while playing (mediaPlayer is released)
545
531
  }
546
532
  }
547
533
  };
@@ -549,10 +535,7 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
549
535
  }
550
536
 
551
537
  private void updateCurrentTime(boolean needUpdateProgress) {
552
- // TODO: check the case after drag the progress indicator and hit play, it'll play a little bit earlier than the progress indicator
553
-
554
538
  int currentPosition = mediaPlayer.getCurrentPosition();
555
-
556
539
  int duration = mDuration;
557
540
 
558
541
  if (currentPosition >= duration - 100) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "2.2.5",
3
+ "version": "2.2.6",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",