cordova-plugin-media3 1.1.8 → 1.1.10

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.
package/README.md CHANGED
@@ -174,13 +174,8 @@ For more information on setting up Cordova see [the documentation](http://cordov
174
174
 
175
175
  For more info on plugins see the [Plugin Development Guide](http://cordova.apache.org/docs/en/latest/guide/hybrid/plugins/index.html)
176
176
 
177
- General ExoPlayer [documentation](https://google.github.io/ExoPlayer/)
177
+ General Media3 ExoPlayer [documentation](https://developer.android.com/media/media3/)
178
178
 
179
- ExoPlayer [source code](https://github.com/google/ExoPlayer)
180
- https://github.com/frontyard/cordova-plugin-exoplayer
181
-
182
- ## Donation
183
- If this project helps you consider donating to support it!
184
179
 
185
180
  ## License
186
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-media3",
3
- "version": "1.1.008",
3
+ "version": "1.1.010",
4
4
  "description": "Media player for Cordova using Google's media3 ExoPlayer framework",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-media3",
@@ -33,6 +33,7 @@ import android.net.*;
33
33
  import android.view.*;
34
34
  import android.widget.*;
35
35
  import android.os.Handler;
36
+ import android.os.Looper;
36
37
 
37
38
  import androidx.annotation.NonNull;
38
39
  import androidx.appcompat.widget.ContentFrameLayout;
@@ -547,7 +548,6 @@ public class Player {
547
548
  }
548
549
 
549
550
  public void pause() {
550
-
551
551
  if (null != exoPlayer) {
552
552
  paused = true;
553
553
  exoPlayer.setPlayWhenReady(false);
@@ -556,18 +556,20 @@ public class Player {
556
556
  }
557
557
 
558
558
  public void play() {
559
- paused = false;
560
- exoPlayer.setPlayWhenReady(true);
561
- startTimeUpdates();
559
+ if (null != exoPlayer) {
560
+ paused = false;
561
+ exoPlayer.setPlayWhenReady(true);
562
+ startTimeUpdates();
563
+ }
562
564
  }
563
565
 
564
566
  public void stop() {
565
- Log.i(TAG, "STOP" + ( (null == exoPlayer) ? " exoPlayer not yet initialized" : ""));
566
-
567
- paused = false;
568
- exoPlayer.stop();
569
-
570
- stopTimeUpdates();
567
+ // Log.i(TAG, "STOP" + ( (null == exoPlayer) ? " exoPlayer not yet initialized" : ""));
568
+ if (null != exoPlayer) {
569
+ paused = false;
570
+ exoPlayer.stop();
571
+ stopTimeUpdates();
572
+ }
571
573
  }
572
574
 
573
575
  private long normalizeOffset(long newTime) {
@@ -673,7 +675,8 @@ public class Player {
673
675
  for (int i = 0; i < group.length; i++) {
674
676
  try {
675
677
  Format format = group.getTrackFormat(i);
676
- int format_id = Integer.parseInt(format.id);
678
+ String track_id = format.id.split("/")[0];
679
+ int format_id = Integer.parseInt(track_id);
677
680
 
678
681
  if (trackId == format_id) {
679
682
  // response.put("Founded " + i, format.toString());
@@ -736,7 +739,8 @@ public class Player {
736
739
  if (group.getType() == C.TRACK_TYPE_TEXT) {
737
740
  for (int i = 0; i < group.length; i++) {
738
741
  Format format = group.getTrackFormat(i);
739
- int formatId = Integer.parseInt(format.id);
742
+ String track_id = format.id.split("/")[0];
743
+ int format_id = Integer.parseInt(track_id);
740
744
 
741
745
  try {
742
746
  if (trackId == formatId) {
@@ -918,13 +922,13 @@ public class Player {
918
922
  }
919
923
 
920
924
  private void startTimeUpdates() {
921
- Map<String, String> map = new HashMap<String, String>();
922
- map.put("message", "startTimeUpdates started");
923
- JSONObject message = new JSONObject(map);
925
+ // Map<String, String> map = new HashMap<String, String>();
926
+ // map.put("message", "startTimeUpdates started");
927
+ // JSONObject message = new JSONObject(map);
924
928
 
925
- new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, message, true);
929
+ // new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, message, true);
926
930
 
927
- timeHandler = new Handler();
931
+ timeHandler = new Handler(Looper.getMainLooper());
928
932
  timeRunnable = new Runnable() {
929
933
  @Override
930
934
  public void run() {
@@ -939,7 +943,15 @@ public class Player {
939
943
  new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, payload, true);
940
944
  }
941
945
  }
942
- timeHandler.postDelayed(this, 1000);
946
+ if (timeHandler != null) {
947
+ timeHandler.postDelayed(this, 1000); // Use actual delay and runnable
948
+ } else {
949
+ // A warning log could be added here to help diagnose
950
+ // why the handler was null at this point, e.g.,
951
+ // Log.w("Player", "Attempted to post delayed task with null Handler.");
952
+ }
953
+
954
+ // timeHandler.postDelayed(this, 1000);
943
955
  }
944
956
  };
945
957
  timeHandler.postDelayed(timeRunnable, 1000);
@@ -950,10 +962,10 @@ public class Player {
950
962
  timeHandler.removeCallbacks(timeRunnable);
951
963
  timeHandler = null;
952
964
 
953
- Map<String, String> map = new HashMap<String, String>();
954
- map.put("message", "Timer stopped");
955
- JSONObject message = new JSONObject(map);
956
- new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, message, true);
965
+ // Map<String, String> map = new HashMap<String, String>();
966
+ // map.put("message", "Timer stopped");
967
+ // JSONObject message = new JSONObject(map);
968
+ // new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, message, true);
957
969
  }
958
970
  }
959
971