cordova-plugin-media3 1.1.24 → 1.1.25
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 +1 -1
- package/src/android/Player.java +11 -12
package/package.json
CHANGED
package/src/android/Player.java
CHANGED
|
@@ -39,7 +39,6 @@ import androidx.annotation.NonNull;
|
|
|
39
39
|
import androidx.appcompat.widget.ContentFrameLayout;
|
|
40
40
|
|
|
41
41
|
// Media3 imports
|
|
42
|
-
import androidx.media3.common.Player;
|
|
43
42
|
import androidx.media3.common.*;
|
|
44
43
|
import androidx.media3.exoplayer.*;
|
|
45
44
|
import androidx.media3.exoplayer.source.*;
|
|
@@ -88,7 +87,7 @@ public class Player {
|
|
|
88
87
|
this.audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
private
|
|
90
|
+
private ExoPlayer.Listener playerEventListener = new ExoPlayer.Listener() {
|
|
92
91
|
@Override
|
|
93
92
|
public void onIsLoadingChanged(boolean isLoading) {
|
|
94
93
|
// JSONObject payload = Payload.loadingEvent(Player.this.exoPlayer, isLoading);
|
|
@@ -109,14 +108,14 @@ public class Player {
|
|
|
109
108
|
@Override
|
|
110
109
|
public void onPlaybackStateChanged(int playbackState) {
|
|
111
110
|
if (config.getShowBuffering()) {
|
|
112
|
-
LayoutProvider.setBufferingVisibility(exoView, activity, playbackState == Player.STATE_BUFFERING);
|
|
111
|
+
LayoutProvider.setBufferingVisibility(exoView, activity, playbackState == androidx.media3.common.Player.STATE_BUFFERING);
|
|
113
112
|
}
|
|
114
113
|
JSONObject payload = Payload.stateEvent(Player.this.exoPlayer, playbackState, Player.this.controllerVisibility == View.VISIBLE);
|
|
115
114
|
new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, payload, true);
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
@Override
|
|
119
|
-
public void onPositionDiscontinuity(@NonNull Player.PositionInfo oldPosition, @NonNull Player.PositionInfo newPosition, int reason) {
|
|
118
|
+
public void onPositionDiscontinuity(@NonNull androidx.media3.common.Player.PositionInfo oldPosition, @NonNull androidx.media3.common.Player.PositionInfo newPosition, int reason) {
|
|
120
119
|
JSONObject payload = Payload.positionDiscontinuityEvent(Player.this.exoPlayer, reason);
|
|
121
120
|
new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, payload, true);
|
|
122
121
|
}
|
|
@@ -232,8 +231,8 @@ public class Player {
|
|
|
232
231
|
public void createPlayer() {
|
|
233
232
|
Log.i(TAG, "Playing " + config.getUri());
|
|
234
233
|
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
String mediaUrl = config.getUri(); // Your method to get the URL
|
|
235
|
+
if (mediaUrl != null && URLUtil.isValidUrl(mediaUrl)) {
|
|
237
236
|
// Proceed with ExoPlayer setup using mediaUrl
|
|
238
237
|
if (config.useInlineView()) {
|
|
239
238
|
// Using a dialog doesn't work for us, as controls are drawn in HTML view (cordova ui)
|
|
@@ -248,11 +247,11 @@ public class Player {
|
|
|
248
247
|
if (config.useInlineView()) {
|
|
249
248
|
setController(config.getController());
|
|
250
249
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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);
|
|
254
|
+
}
|
|
256
255
|
}
|
|
257
256
|
|
|
258
257
|
public void createDialog() {
|
|
@@ -606,7 +605,7 @@ public class Player {
|
|
|
606
605
|
|
|
607
606
|
public JSONObject getPlayerState() {
|
|
608
607
|
return Payload.stateEvent(exoPlayer,
|
|
609
|
-
null != exoPlayer ? exoPlayer.getPlaybackState() : Player.STATE_ENDED,
|
|
608
|
+
null != exoPlayer ? exoPlayer.getPlaybackState() : androidx.media3.common.Player.STATE_ENDED,
|
|
610
609
|
Player.this.controllerVisibility == View.VISIBLE);
|
|
611
610
|
}
|
|
612
611
|
|