cordova-plugin-media3 1.1.16 → 1.1.18
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/plugin.xml +2 -1
- package/src/android/Payload.java +28 -23
- package/src/android/Player.java +53 -2
- package/www/exoplayer.js +5 -2
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
<framework src="androidx.media3:media3-extractor:1.8.0"/>
|
|
30
30
|
<framework src="androidx.media3:media3-decoder:1.8.0"/>
|
|
31
31
|
<!-- <framework src="androidx.media3:media3-session:1.8.0"/> -->
|
|
32
|
-
<!-- <framework src="
|
|
32
|
+
<!-- <framework src="androidx.media3:media3-exoplayer-ffmpeg:1.0.0"/> -->
|
|
33
|
+
<framework src="org.jellyfin.media3:media3-ffmpeg-decoder:1.8.0+1"/>
|
|
33
34
|
<framework src="com.squareup.picasso:picasso:2.8"/>
|
|
34
35
|
|
|
35
36
|
<config-file target="res/xml/config.xml" parent="/*">
|
package/src/android/Payload.java
CHANGED
|
@@ -125,7 +125,7 @@ public class Payload {
|
|
|
125
125
|
Map<String, String> map = new HashMap<String, String>();
|
|
126
126
|
map.put("eventType", "SEEK_EVENT");
|
|
127
127
|
map.put("offset", Long.toString(offset));
|
|
128
|
-
addPlayerState(map, player);
|
|
128
|
+
// addPlayerState(map, player);
|
|
129
129
|
return new JSONObject(map);
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -207,30 +207,18 @@ public class Payload {
|
|
|
207
207
|
return new JSONObject(map);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
public static JSONObject timeUpdateEvent(ExoPlayer player) {
|
|
211
|
+
Map<String, String> map = new HashMap<String, String>();
|
|
212
|
+
map.put("eventType", "TIMEUPDATE_EVENT");
|
|
211
213
|
if (null != player) {
|
|
212
214
|
try {
|
|
213
|
-
map.put("duration", Long.toString(player.getDuration()));
|
|
214
215
|
map.put("position", Long.toString(player.getCurrentPosition()));
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
map.put("bufferPercentage", Integer.toString(player.getBufferedPercentage()));
|
|
218
|
-
map.put("videoWidth", Integer.toString(player.getVideoSize().width));
|
|
219
|
-
map.put("videoHeight", Integer.toString(player.getVideoSize().height));
|
|
220
|
-
}
|
|
221
|
-
catch(Exception ex) {
|
|
222
|
-
Log.e(Player.TAG, "Error adding player state", ex);
|
|
216
|
+
} catch (Exception ex) {
|
|
217
|
+
// Log.e(Player.TAG, "Error adding player getCurrentPosition", ex);
|
|
223
218
|
}
|
|
224
219
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
public static JSONObject timeUpdateEvent(ExoPlayer player) {
|
|
229
|
-
Map<String, String> map = new HashMap<String, String>();
|
|
230
|
-
map.put("eventType", "TIMEUPDATE_EVENT");
|
|
231
|
-
map.put("message", "Timer running");
|
|
232
|
-
// map.put("playbackState", playbackStateToString(playbackState));
|
|
233
|
-
addPlayerState(map, player);
|
|
220
|
+
// map.put("message", "Timer running");
|
|
221
|
+
// addPlayerState(map, player);
|
|
234
222
|
return new JSONObject(map);
|
|
235
223
|
}
|
|
236
224
|
|
|
@@ -255,7 +243,7 @@ public class Payload {
|
|
|
255
243
|
map.put("tracks", result.toString());
|
|
256
244
|
} catch (JSONException e) {
|
|
257
245
|
// e.printStackTrace();
|
|
258
|
-
Log.e(Player.TAG, "Error adding tracks info", e);
|
|
246
|
+
// Log.e(Player.TAG, "Error adding tracks info", e);
|
|
259
247
|
}
|
|
260
248
|
|
|
261
249
|
}
|
|
@@ -274,7 +262,7 @@ public class Payload {
|
|
|
274
262
|
trackObj.put("format", format.sampleMimeType);
|
|
275
263
|
} catch (JSONException e) {
|
|
276
264
|
// e.printStackTrace();
|
|
277
|
-
Log.e(Player.TAG, "Error adding trackObj info", e);
|
|
265
|
+
// Log.e(Player.TAG, "Error adding trackObj info", e);
|
|
278
266
|
}
|
|
279
267
|
|
|
280
268
|
switch (group.getType()) {
|
|
@@ -301,7 +289,7 @@ public class Payload {
|
|
|
301
289
|
result.put("subtitleTracks", subtitleArray);
|
|
302
290
|
} catch (JSONException e) {
|
|
303
291
|
// e.printStackTrace();
|
|
304
|
-
Log.e(Player.TAG, "Error adding tracks info", e);
|
|
292
|
+
// Log.e(Player.TAG, "Error adding tracks info", e);
|
|
305
293
|
}
|
|
306
294
|
|
|
307
295
|
map.put("tracks", result.toString());
|
|
@@ -309,6 +297,23 @@ public class Payload {
|
|
|
309
297
|
}
|
|
310
298
|
}
|
|
311
299
|
|
|
300
|
+
private static void addPlayerState(Map<String, String> map, ExoPlayer player) {
|
|
301
|
+
if (null != player) {
|
|
302
|
+
try {
|
|
303
|
+
map.put("duration", Long.toString(player.getDuration()));
|
|
304
|
+
map.put("position", Long.toString(player.getCurrentPosition()));
|
|
305
|
+
map.put("playWhenReady", Boolean.toString(player.getPlayWhenReady()));
|
|
306
|
+
map.put("playbackState", playbackStateToString(player.getPlaybackState()));
|
|
307
|
+
map.put("bufferPercentage", Integer.toString(player.getBufferedPercentage()));
|
|
308
|
+
map.put("videoWidth", Integer.toString(player.getVideoSize().width));
|
|
309
|
+
map.put("videoHeight", Integer.toString(player.getVideoSize().height));
|
|
310
|
+
}
|
|
311
|
+
catch(Exception ex) {
|
|
312
|
+
// Log.e(Player.TAG, "Error adding player state", ex);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
312
317
|
// public static JSONObject audioTrackeEvent(ExoPlayer player) {
|
|
313
318
|
// Map<String, String> map = new HashMap<String, String>();
|
|
314
319
|
// Tracks currentTracks = player.getCurrentTracks();
|
package/src/android/Player.java
CHANGED
|
@@ -90,8 +90,8 @@ public class Player {
|
|
|
90
90
|
private androidx.media3.common.Player.Listener playerEventListener = new androidx.media3.common.Player.Listener() {
|
|
91
91
|
@Override
|
|
92
92
|
public void onIsLoadingChanged(boolean isLoading) {
|
|
93
|
-
JSONObject payload = Payload.loadingEvent(Player.this.exoPlayer, isLoading);
|
|
94
|
-
new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, payload, true);
|
|
93
|
+
// JSONObject payload = Payload.loadingEvent(Player.this.exoPlayer, isLoading);
|
|
94
|
+
// new CallbackResponse(Player.this.callbackContext).send(PluginResult.Status.OK, payload, true);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
@Override
|
|
@@ -880,6 +880,57 @@ public class Player {
|
|
|
880
880
|
return response;
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
+
public JSONObject setAspectRatio(String aspectRatio) {
|
|
884
|
+
JSONObject response = new JSONObject();
|
|
885
|
+
|
|
886
|
+
try {
|
|
887
|
+
if (exoView == null) {
|
|
888
|
+
response.put("success", false);
|
|
889
|
+
response.put("message", "Player view not initialized");
|
|
890
|
+
return response;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// Convert string to appropriate resize mode
|
|
894
|
+
int resizeMode = getResizeModeFromString(aspectRatio);
|
|
895
|
+
|
|
896
|
+
// Set the resize mode on the player view
|
|
897
|
+
exoView.setResizeMode(resizeMode);
|
|
898
|
+
|
|
899
|
+
response.put("success", true);
|
|
900
|
+
response.put("message", "Aspect ratio set to: " + resizeMode);
|
|
901
|
+
// response.put("resizeMode", resizeMode);
|
|
902
|
+
|
|
903
|
+
} catch (JSONException e) {
|
|
904
|
+
try {
|
|
905
|
+
response.put("success", false);
|
|
906
|
+
response.put("error", "Failed to set aspect ratio: " + e.getMessage());
|
|
907
|
+
} catch (JSONException je) {
|
|
908
|
+
Log.e(TAG, "Error creating response JSON", je);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
return response;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
private int getResizeModeFromString(String aspectRatio) {
|
|
916
|
+
switch (aspectRatio.toUpperCase()) {
|
|
917
|
+
case "FIT":
|
|
918
|
+
case "FIT_SCREEN":
|
|
919
|
+
return AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
|
920
|
+
case "FILL":
|
|
921
|
+
case "FILL_SCREEN":
|
|
922
|
+
return AspectRatioFrameLayout.RESIZE_MODE_FILL;
|
|
923
|
+
case "FIXED_WIDTH":
|
|
924
|
+
return AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH;
|
|
925
|
+
case "FIXED_HEIGHT":
|
|
926
|
+
return AspectRatioFrameLayout.RESIZE_MODE_FIXED_HEIGHT;
|
|
927
|
+
case "ZOOM":
|
|
928
|
+
return AspectRatioFrameLayout.RESIZE_MODE_ZOOM;
|
|
929
|
+
default:
|
|
930
|
+
Log.w(TAG, "Unknown aspect ratio: " + aspectRatio + ", defaulting to FIT");
|
|
931
|
+
return AspectRatioFrameLayout.RESIZE_MODE_FIT;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
883
934
|
private int getColor(String color) {
|
|
884
935
|
switch (color) {
|
|
885
936
|
case "transparent":
|
package/www/exoplayer.js
CHANGED
|
@@ -79,8 +79,11 @@ module.exports = {
|
|
|
79
79
|
setSubtitleStyle: function (subtitle_color, subtitle_background, edgeColor, edgeType, successCallback, errorCallback) {
|
|
80
80
|
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setSubtitleStyle", [subtitle_color, subtitle_background, edgeColor, edgeType]);
|
|
81
81
|
},
|
|
82
|
-
isTV: function (successCallback, errorCallback) {
|
|
83
|
-
|
|
82
|
+
// isTV: function (successCallback, errorCallback) {
|
|
83
|
+
// cordova.exec(successCallback, errorCallback, "ExoPlayer", "isTV", []);
|
|
84
|
+
// },
|
|
85
|
+
setAspectRatio: function (aspectRatio, successCallback, errorCallback) {
|
|
86
|
+
cordova.exec(successCallback, errorCallback, "ExoPlayer", "setAspectRatio", [aspectRatio]);
|
|
84
87
|
},
|
|
85
88
|
getDuration: function (successCallback, errorCallback) {
|
|
86
89
|
cordova.exec(successCallback, errorCallback, "ExoPlayer", "getDuration", []);
|