cordova-plugin-media3 1.1.18 → 1.1.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-media3",
3
- "version": "1.1.018",
3
+ "version": "1.1.020",
4
4
  "description": "Media player for Cordova using Google's media3 ExoPlayer framework",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-media3",
@@ -25,6 +25,7 @@ package co.frontyard.cordova.plugin.exoplayer;
25
25
 
26
26
  import android.util.Log;
27
27
  import android.view.*;
28
+ import androidx.media3.common.Player;
28
29
  import androidx.media3.common.*;
29
30
  import androidx.media3.exoplayer.*;
30
31
  import androidx.media3.exoplayer.trackselection.*;
@@ -45,7 +46,7 @@ public class Payload {
45
46
  public static String playbackStateToString(int playbackState) {
46
47
  String state = "UNKNOWN";
47
48
  switch (playbackState) {
48
- case androidx.media3.common.Player.STATE_IDLE:
49
+ case Player.STATE_IDLE:
49
50
  state = "STATE_IDLE";
50
51
  break;
51
52
  case androidx.media3.common.Player.STATE_BUFFERING:
@@ -231,18 +231,26 @@ public class Player {
231
231
  public void createPlayer() {
232
232
  Log.i(TAG, "Playing " + config.getUri());
233
233
 
234
- if (config.useInlineView()) {
235
- // Using a dialog doesn't work for us, as controls are drawn in HTML view (cordova ui)
236
- // createPlayerInCordovaUI();
237
- createTransparentPlayer();
238
-
239
- } else if (!config.isAudioOnly()) {
240
- createDialog();
241
- }
242
- preparePlayer(config.getUri());
234
+ String mediaUrl = config.getUri(); // Your method to get the URL
235
+ if (mediaUrl != null && URLUtil.isValidUrl(mediaUrl)) {
236
+ // Proceed with ExoPlayer setup using mediaUrl
237
+ if (config.useInlineView()) {
238
+ // Using a dialog doesn't work for us, as controls are drawn in HTML view (cordova ui)
239
+ // createPlayerInCordovaUI();
240
+ createTransparentPlayer();
241
+
242
+ } else if (!config.isAudioOnly()) {
243
+ createDialog();
244
+ }
245
+ preparePlayer(config.getUri());
243
246
 
244
- if (config.useInlineView()) {
245
- setController(config.getController());
247
+ if (config.useInlineView()) {
248
+ setController(config.getController());
249
+ }
250
+ } else {
251
+ // Handle invalid or null URL: e.g., show an error message, log the issue, or use a placeholder.
252
+ Log.e("ExoPlayerDebug", "Invalid media URL: " + mediaUrl);
253
+ sendError("Invalid media URL: " + uri);
246
254
  }
247
255
  }
248
256
 
@@ -265,6 +265,26 @@ public class Plugin extends CordovaPlugin {
265
265
  }
266
266
  });
267
267
  return true;
268
+ // } else if (action.equals("isTV")) {
269
+ // cordova.getActivity().runOnUiThread(new Runnable() {
270
+ // public void run() {
271
+ // JSONObject response = DeviceDetector.isTV(cordova.getActivity());
272
+ // new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, true);
273
+ // }
274
+ // });
275
+ // return true;
276
+ } else if (action.equals("setAspectRatio")) {
277
+ if (self.player == null) {
278
+ return false;
279
+ }
280
+ final String aspectRatio = data.optString(0);
281
+ cordova.getActivity().runOnUiThread(new Runnable() {
282
+ public void run() {
283
+ JSONObject response = self.player.setAspectRatio(aspectRatio);
284
+ new CallbackResponse(callbackContext).send(PluginResult.Status.OK, response, true);
285
+ }
286
+ });
287
+ return true;
268
288
  } else {
269
289
  new CallbackResponse(callbackContext).send(PluginResult.Status.INVALID_ACTION, false);
270
290
  return false;