@capgo/capacitor-jw-player 0.0.1 → 0.0.12
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/CapgoCapacitorJwPlayer.podspec +3 -1
- package/Package.swift +12 -2
- package/README.md +19 -4
- package/android/build.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/ee/forgr/capacitor_jw_player/CastOptionsProvider.java +30 -0
- package/android/src/main/java/ee/forgr/capacitor_jw_player/JwPlayerPlugin.java +63 -59
- package/android/src/main/java/ee/forgr/capacitor_jw_player/PlayerActivity.java +72 -73
- package/dist/docs.json +6 -2
- package/dist/esm/definitions.d.ts +2 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/ios/Sources/JwPlayerPlugin/JwPlayer.swift +4 -4
- package/ios/Sources/JwPlayerPlugin/JwPlayerPlugin.swift +218 -120
- package/ios/Sources/JwPlayerPlugin/LinkedList.swift +28 -29
- package/ios/Sources/JwPlayerPlugin/VideosToPlay.swift +4 -5
- package/package.json +5 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package ee.forgr.capacitor_jw_player;
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
|
+
import android.content.Context;
|
|
4
5
|
import android.content.Intent;
|
|
5
6
|
import android.content.res.Configuration;
|
|
6
7
|
import android.graphics.Rect;
|
|
@@ -15,9 +16,12 @@ import android.view.ViewGroup;
|
|
|
15
16
|
import android.view.WindowManager;
|
|
16
17
|
import android.widget.ImageButton;
|
|
17
18
|
import android.widget.ImageView;
|
|
18
|
-
|
|
19
19
|
import androidx.appcompat.app.AppCompatActivity;
|
|
20
|
-
|
|
20
|
+
import com.google.android.gms.cast.CastMediaControlIntent;
|
|
21
|
+
import com.google.android.gms.cast.LaunchOptions;
|
|
22
|
+
import com.google.android.gms.cast.framework.CastOptions;
|
|
23
|
+
import com.google.android.gms.cast.framework.OptionsProvider;
|
|
24
|
+
import com.google.android.gms.cast.framework.SessionProvider;
|
|
21
25
|
import com.jwplayer.pub.api.JWPlayer;
|
|
22
26
|
import com.jwplayer.pub.api.PlayerState;
|
|
23
27
|
import com.jwplayer.pub.api.UiGroup;
|
|
@@ -25,8 +29,8 @@ import com.jwplayer.pub.api.configuration.PlayerConfig;
|
|
|
25
29
|
// import com.jwplayer.pub.api.configuration.PlaylistConfig; // Already commented/removed - ensure it's gone
|
|
26
30
|
import com.jwplayer.pub.api.configuration.UiConfig;
|
|
27
31
|
import com.jwplayer.pub.api.events.*;
|
|
28
|
-
import com.jwplayer.pub.api.events.listeners.VideoPlayerEvents;
|
|
29
32
|
import com.jwplayer.pub.api.events.listeners.AdvertisingEvents;
|
|
33
|
+
import com.jwplayer.pub.api.events.listeners.VideoPlayerEvents;
|
|
30
34
|
import com.jwplayer.pub.api.license.LicenseUtil;
|
|
31
35
|
import com.jwplayer.pub.api.media.captions.Caption;
|
|
32
36
|
import com.jwplayer.pub.api.media.captions.CaptionType;
|
|
@@ -35,11 +39,13 @@ import com.jwplayer.pub.api.media.playlists.PlaylistItem;
|
|
|
35
39
|
import com.jwplayer.pub.ui.viewmodels.ControlbarViewModel;
|
|
36
40
|
import com.jwplayer.pub.view.JWPlayerView;
|
|
37
41
|
import com.jwplayer.ui.views.ControlbarView;
|
|
38
|
-
|
|
39
42
|
import java.util.ArrayList;
|
|
40
43
|
import java.util.List;
|
|
44
|
+
import java.util.Locale;
|
|
41
45
|
|
|
42
|
-
public class PlayerActivity
|
|
46
|
+
public class PlayerActivity
|
|
47
|
+
extends AppCompatActivity
|
|
48
|
+
implements
|
|
43
49
|
VideoPlayerEvents.OnFullscreenListener,
|
|
44
50
|
VideoPlayerEvents.OnReadyListener,
|
|
45
51
|
VideoPlayerEvents.OnErrorListener,
|
|
@@ -54,12 +60,12 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
54
60
|
VideoPlayerEvents.OnTimeListener,
|
|
55
61
|
AdvertisingEvents.OnAdErrorListener,
|
|
56
62
|
AdvertisingEvents.OnAdWarningListener,
|
|
57
|
-
VideoPlayerEvents.OnMetaListener
|
|
58
|
-
{
|
|
63
|
+
VideoPlayerEvents.OnMetaListener {
|
|
59
64
|
|
|
60
65
|
private static final String TAG = "PlayerActivity";
|
|
61
66
|
public static final String EXTRA_MEDIA_URL = "mediaUrl";
|
|
62
67
|
public static final String EXTRA_MEDIA_TYPE = "mediaType";
|
|
68
|
+
public static final String AUTOSTART = "autostartMedia";
|
|
63
69
|
|
|
64
70
|
private JWPlayerView mPlayerView;
|
|
65
71
|
private JWPlayer mPlayer;
|
|
@@ -74,14 +80,13 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
74
80
|
|
|
75
81
|
// Make activity fullscreen - moved after setContentView
|
|
76
82
|
if (getWindow() != null) {
|
|
77
|
-
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
78
|
-
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
83
|
+
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
79
84
|
// Keep the screen on during playback
|
|
80
85
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
81
86
|
} else {
|
|
82
87
|
Log.e(TAG, "Window is null in onCreate!");
|
|
83
88
|
}
|
|
84
|
-
|
|
89
|
+
|
|
85
90
|
// Hide navigation bar and enable immersive mode
|
|
86
91
|
hideSystemUI();
|
|
87
92
|
|
|
@@ -94,29 +99,27 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
94
99
|
ImageView enterFullScreenButton = customControlBar.findViewById(com.longtailvideo.jwplayer.R.id.controlbar_enter_fullscreen_btn);
|
|
95
100
|
ImageView exitFullScreenButton = customControlBar.findViewById(com.longtailvideo.jwplayer.R.id.controlbar_exit_fullscreen_btn);
|
|
96
101
|
if (enterFullScreenButton != null && enterFullScreenButton.getParent() != null) {
|
|
97
|
-
((ViewGroup)enterFullScreenButton.getParent()).removeView(enterFullScreenButton);
|
|
102
|
+
((ViewGroup) enterFullScreenButton.getParent()).removeView(enterFullScreenButton);
|
|
98
103
|
}
|
|
99
104
|
if (exitFullScreenButton != null && exitFullScreenButton.getParent() != null) {
|
|
100
|
-
((ViewGroup)exitFullScreenButton.getParent()).removeView(exitFullScreenButton);
|
|
105
|
+
((ViewGroup) exitFullScreenButton.getParent()).removeView(exitFullScreenButton);
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
// Setup Close Button
|
|
104
109
|
mCloseButton = findViewById(R.id.close_button);
|
|
105
110
|
mCloseButton.setOnClickListener(v -> finish());
|
|
106
111
|
|
|
107
|
-
ControlbarViewModel controlbarViewModel =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
mCloseButton.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
|
|
112
|
+
ControlbarViewModel controlbarViewModel = (ControlbarViewModel) mPlayer.getViewModelForUiGroup(UiGroup.CONTROLBAR);
|
|
113
|
+
|
|
114
|
+
controlbarViewModel
|
|
115
|
+
.isUiLayerVisible()
|
|
116
|
+
.observe(this, isVisible -> {
|
|
117
|
+
if (isInPictureInPictureMode()) {
|
|
118
|
+
mCloseButton.setVisibility(View.GONE);
|
|
119
|
+
return;
|
|
118
120
|
}
|
|
119
|
-
|
|
121
|
+
mCloseButton.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
|
|
122
|
+
});
|
|
120
123
|
|
|
121
124
|
// Set the static instance reference in the plugin
|
|
122
125
|
JwPlayerPlugin.setStaticPlayerInstance(mPlayer);
|
|
@@ -133,10 +136,11 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
133
136
|
Intent intent = getIntent();
|
|
134
137
|
String mediaUrl = intent.getStringExtra(EXTRA_MEDIA_URL);
|
|
135
138
|
String mediaType = intent.getStringExtra(EXTRA_MEDIA_TYPE);
|
|
139
|
+
boolean autostart = intent.getBooleanExtra(AUTOSTART, false);
|
|
136
140
|
|
|
137
141
|
if (mediaUrl != null && mediaType != null) {
|
|
138
142
|
Log.d(TAG, "Received Media URL: " + mediaUrl + ", Type: " + mediaType);
|
|
139
|
-
loadMedia(mediaUrl, mediaType);
|
|
143
|
+
loadMedia(mediaUrl, mediaType, autostart);
|
|
140
144
|
} else {
|
|
141
145
|
Log.e(TAG, "Error: Media URL or Type not provided in Intent.");
|
|
142
146
|
// Notify plugin of error?
|
|
@@ -144,20 +148,17 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
private void loadMedia(String mediaUrl, String mediaType) {
|
|
151
|
+
private void loadMedia(String mediaUrl, String mediaType, boolean autostart) {
|
|
148
152
|
PlaylistItem playlistItem = new PlaylistItem.Builder()
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
.file(mediaUrl)
|
|
154
|
+
// .title("Video Title") // Optional
|
|
155
|
+
// .description("Video Description") // Optional
|
|
156
|
+
.build();
|
|
153
157
|
|
|
154
158
|
List<PlaylistItem> playlist = new ArrayList<>();
|
|
155
159
|
playlist.add(playlistItem);
|
|
156
160
|
|
|
157
|
-
PlayerConfig config = new PlayerConfig.Builder()
|
|
158
|
-
.playlist(playlist)
|
|
159
|
-
.autostart(true)
|
|
160
|
-
.build();
|
|
161
|
+
PlayerConfig config = new PlayerConfig.Builder().playlist(playlist).autostart(autostart).build();
|
|
161
162
|
|
|
162
163
|
mPlayer.setup(config);
|
|
163
164
|
Log.d(TAG, "Player setup initiated.");
|
|
@@ -195,7 +196,7 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
195
196
|
super.onPause();
|
|
196
197
|
Log.d(TAG, "onPause");
|
|
197
198
|
if (mPlayer != null && !isInPictureInPictureMode()) { // Don't pause if entering PiP
|
|
198
|
-
|
|
199
|
+
// mPlayer.pause();
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
|
|
@@ -244,11 +245,13 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
244
245
|
public void onUserLeaveHint() {
|
|
245
246
|
// Enter PiP if supported when user navigates away (e.g., home button)
|
|
246
247
|
super.onUserLeaveHint();
|
|
247
|
-
if (
|
|
248
|
-
|
|
248
|
+
if (
|
|
249
|
+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
|
250
|
+
getPackageManager().hasSystemFeature(getPackageManager().FEATURE_PICTURE_IN_PICTURE)
|
|
251
|
+
) {
|
|
249
252
|
if (mPlayer != null && mPlayer.getState() == PlayerState.PLAYING) {
|
|
250
|
-
|
|
251
|
-
|
|
253
|
+
Log.d(TAG, "User leaving hint, entering PiP mode.");
|
|
254
|
+
// enterPictureInPictureMode();
|
|
252
255
|
}
|
|
253
256
|
}
|
|
254
257
|
}
|
|
@@ -268,7 +271,6 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
268
271
|
// PiP is active, hide controls like the close button
|
|
269
272
|
mCloseButton.setVisibility(View.GONE);
|
|
270
273
|
} else {
|
|
271
|
-
|
|
272
274
|
// PiP is inactive, restore UI
|
|
273
275
|
mCloseButton.setVisibility(View.VISIBLE);
|
|
274
276
|
if (getWindow() != null) {
|
|
@@ -319,7 +321,7 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
319
321
|
JwPlayerPlugin.notifyPlaylistComplete();
|
|
320
322
|
finish(); // Close activity when playlist finishes
|
|
321
323
|
}
|
|
322
|
-
|
|
324
|
+
|
|
323
325
|
public void onPause(PauseEvent pauseEvent) {
|
|
324
326
|
Log.d(TAG, "onPause event: state=" + pauseEvent.getOldState());
|
|
325
327
|
JwPlayerPlugin.notifyPause(pauseEvent.getPauseReason().name());
|
|
@@ -337,15 +339,15 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
337
339
|
float aspectRatio = (float) metadata.getWidth() / metadata.getHeight();
|
|
338
340
|
int width = metadata.getWidth();
|
|
339
341
|
int height = metadata.getHeight();
|
|
340
|
-
|
|
342
|
+
|
|
341
343
|
if (aspectRatio > 2.38f) {
|
|
342
344
|
// Too wide, adjust width, let's not handle it
|
|
343
345
|
return;
|
|
344
|
-
} else if (aspectRatio < 1/2.38f) {
|
|
346
|
+
} else if (aspectRatio < 1 / 2.38f) {
|
|
345
347
|
// Too tall, adjust height, let's not handle it for now
|
|
346
348
|
return;
|
|
347
349
|
}
|
|
348
|
-
|
|
350
|
+
|
|
349
351
|
Rational rational = new Rational(width, height);
|
|
350
352
|
// Get the display metrics for the current screen
|
|
351
353
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
@@ -353,13 +355,13 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
353
355
|
int screenWidth = displayMetrics.widthPixels;
|
|
354
356
|
|
|
355
357
|
// Calculate one-third of screen width and round to nearest even number
|
|
356
|
-
int thirdWidth = (int) Math.round((double)screenWidth / 3.0);
|
|
358
|
+
int thirdWidth = (int) Math.round((double) screenWidth / 3.0);
|
|
357
359
|
if (thirdWidth % 2 != 0) {
|
|
358
360
|
// If odd, round up to next even number
|
|
359
361
|
thirdWidth += 1;
|
|
360
362
|
}
|
|
361
363
|
|
|
362
|
-
int thirdHeight = (int) Math.round(((double)screenWidth / 3.0) * aspectRatio);
|
|
364
|
+
int thirdHeight = (int) Math.round(((double) screenWidth / 3.0) * aspectRatio);
|
|
363
365
|
if (thirdHeight % 2 != 0) {
|
|
364
366
|
// If odd, round up to next even number
|
|
365
367
|
thirdHeight += 1;
|
|
@@ -375,17 +377,17 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
375
377
|
Log.d(TAG, "onComplete event");
|
|
376
378
|
JwPlayerPlugin.notifyComplete();
|
|
377
379
|
}
|
|
378
|
-
|
|
380
|
+
|
|
379
381
|
public void onSeek(SeekEvent seekEvent) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
+
Log.d(TAG, "onSeek event: position=" + seekEvent.getPosition() + ", offset=" + seekEvent.getOffset());
|
|
383
|
+
JwPlayerPlugin.notifySeek(seekEvent.getPosition(), seekEvent.getOffset());
|
|
382
384
|
}
|
|
383
385
|
|
|
384
386
|
public void onSeeked(SeekedEvent seekedEvent) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
+
Log.d(TAG, "onSeeked event");
|
|
388
|
+
JwPlayerPlugin.notifySeeked();
|
|
387
389
|
}
|
|
388
|
-
|
|
390
|
+
|
|
389
391
|
public void onTime(TimeEvent timeEvent) {
|
|
390
392
|
// Log.v(TAG, "onTime event: position=" + timeEvent.getPosition() + ", duration=" + timeEvent.getDuration());
|
|
391
393
|
JwPlayerPlugin.notifyTime(timeEvent.getPosition(), timeEvent.getDuration());
|
|
@@ -398,28 +400,26 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
398
400
|
Log.e(TAG, "Window is null in hideSystemUI!");
|
|
399
401
|
return;
|
|
400
402
|
}
|
|
401
|
-
|
|
403
|
+
|
|
402
404
|
// For AppCompatActivity, use the support library methods
|
|
403
405
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
404
406
|
getWindow().setDecorFitsSystemWindows(false);
|
|
405
407
|
android.view.WindowInsetsController insetsController = getWindow().getInsetsController();
|
|
406
408
|
if (insetsController != null) {
|
|
407
|
-
insetsController.hide(
|
|
408
|
-
|
|
409
|
-
android.view.WindowInsets.Type.navigationBars());
|
|
410
|
-
insetsController.setSystemBarsBehavior(
|
|
411
|
-
android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
409
|
+
insetsController.hide(android.view.WindowInsets.Type.statusBars() | android.view.WindowInsets.Type.navigationBars());
|
|
410
|
+
insetsController.setSystemBarsBehavior(android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
412
411
|
}
|
|
413
412
|
} else {
|
|
414
413
|
// Legacy method for older Android versions
|
|
415
414
|
View decorView = getWindow().getDecorView();
|
|
416
415
|
decorView.setSystemUiVisibility(
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
416
|
+
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
|
|
417
|
+
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
418
|
+
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
419
|
+
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
420
|
+
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
|
421
|
+
View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
422
|
+
);
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
@@ -429,19 +429,18 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
429
429
|
Log.e(TAG, "Window is null in showSystemUI!");
|
|
430
430
|
return;
|
|
431
431
|
}
|
|
432
|
-
|
|
432
|
+
|
|
433
433
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
434
434
|
getWindow().setDecorFitsSystemWindows(true);
|
|
435
|
-
getWindow()
|
|
436
|
-
|
|
437
|
-
|
|
435
|
+
getWindow()
|
|
436
|
+
.getInsetsController()
|
|
437
|
+
.show(android.view.WindowInsets.Type.statusBars() | android.view.WindowInsets.Type.navigationBars());
|
|
438
438
|
} else {
|
|
439
439
|
// Legacy method for older Android versions
|
|
440
440
|
View decorView = getWindow().getDecorView();
|
|
441
441
|
decorView.setSystemUiVisibility(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
|
442
|
+
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
443
|
+
);
|
|
445
444
|
}
|
|
446
445
|
}
|
|
447
446
|
|
|
@@ -451,7 +450,7 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
451
450
|
Log.e(TAG, "Window is null in toggleSystemUI!");
|
|
452
451
|
return;
|
|
453
452
|
}
|
|
454
|
-
|
|
453
|
+
|
|
455
454
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
456
455
|
// For Android 11+, use InsetsController to check visibility
|
|
457
456
|
// Just toggle - there's no direct visibility check for R+
|
|
@@ -466,4 +465,4 @@ public class PlayerActivity extends AppCompatActivity implements
|
|
|
466
465
|
}
|
|
467
466
|
}
|
|
468
467
|
}
|
|
469
|
-
}
|
|
468
|
+
}
|
package/dist/docs.json
CHANGED
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"name": "play",
|
|
39
|
-
"signature": "(options: { mediaUrl: string; mediaType: 'video' | 'playlist'; }) => Promise<void>",
|
|
39
|
+
"signature": "(options: { mediaUrl: string; mediaType: 'video' | 'playlist'; autostart?: boolean; }) => Promise<void>",
|
|
40
40
|
"parameters": [
|
|
41
41
|
{
|
|
42
42
|
"name": "options",
|
|
43
43
|
"docs": "- The options for the JW Player",
|
|
44
|
-
"type": "{ mediaUrl: string; mediaType: 'video' | 'playlist'; }"
|
|
44
|
+
"type": "{ mediaUrl: string; mediaType: 'video' | 'playlist'; autostart?: boolean | undefined; }"
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
47
|
"returns": "Promise<void>",
|
|
@@ -58,6 +58,10 @@
|
|
|
58
58
|
"name": "param",
|
|
59
59
|
"text": "options.mediaType - The type of media to play"
|
|
60
60
|
},
|
|
61
|
+
{
|
|
62
|
+
"name": "param",
|
|
63
|
+
"text": "options.autostart - Whether to start the media automatically. Default is false."
|
|
64
|
+
},
|
|
61
65
|
{
|
|
62
66
|
"name": "returns",
|
|
63
67
|
"text": "A promise that resolves when the command is executed"
|
|
@@ -13,11 +13,13 @@ export interface JwPlayerPlugin {
|
|
|
13
13
|
* @param options - The options for the JW Player
|
|
14
14
|
* @param options.mediaUrl - The URL of the media to play
|
|
15
15
|
* @param options.mediaType - The type of media to play
|
|
16
|
+
* @param options.autostart - Whether to start the media automatically. Default is false.
|
|
16
17
|
* @returns A promise that resolves when the command is executed
|
|
17
18
|
*/
|
|
18
19
|
play(options: {
|
|
19
20
|
mediaUrl: string;
|
|
20
21
|
mediaType: 'video' | 'playlist';
|
|
22
|
+
autostart?: boolean;
|
|
21
23
|
}): Promise<void>;
|
|
22
24
|
/**
|
|
23
25
|
* Pause the currently playing media
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface JwPlayerPlugin {\n /**\n * Initialize the JW Player\n * @param options - The options for the JW Player\n * @param options.licenseKey - The license key for the JW Player. Keep in mind that this is different for iOS and Android.\n * @returns A promise that resolves when initialized\n */\n initialize(options: { licenseKey: string }): Promise<void>;\n
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface JwPlayerPlugin {\n /**\n * Initialize the JW Player\n * @param options - The options for the JW Player\n * @param options.licenseKey - The license key for the JW Player. Keep in mind that this is different for iOS and Android.\n * @returns A promise that resolves when initialized\n */\n initialize(options: { licenseKey: string }): Promise<void>;\n\n /**\n * Play a video\n * @param options - The options for the JW Player\n * @param options.mediaUrl - The URL of the media to play\n * @param options.mediaType - The type of media to play\n * @param options.autostart - Whether to start the media automatically. Default is false.\n * @returns A promise that resolves when the command is executed\n */\n play(options: { mediaUrl: string; mediaType: 'video' | 'playlist'; autostart?: boolean }): Promise<void>;\n\n /**\n * Pause the currently playing media\n * @returns A promise that resolves when the command is executed\n */\n pause(): Promise<void>;\n\n /**\n * Resume the currently paused media\n * @returns A promise that resolves when the command is executed\n */\n resume(): Promise<void>;\n\n /**\n * Stop the currently playing media\n * @returns A promise that resolves when the command is executed\n */\n stop(): Promise<void>;\n\n /**\n * Seek to a specific position in the currently playing media\n * @param options - Options for seeking\n * @param options.time - The position to seek to in seconds\n * @returns A promise that resolves when the command is executed\n */\n seekTo(options: { time: number }): Promise<void>;\n\n /**\n * Set the volume level\n * @param options - Options for setting volume\n * @param options.volume - The volume level (0.0 to 1.0)\n * @returns A promise that resolves when the command is executed\n */\n setVolume(options: { volume: number }): Promise<void>;\n\n /**\n * Get the current position in the media\n * @returns A promise that resolves with the current position in seconds\n */\n getPosition(): Promise<{ position: number }>;\n\n /**\n * Get the current player state\n * @returns A promise that resolves with the player state\n */\n getState(): Promise<{ state: number }>;\n\n /**\n * Set the playback speed\n * @param options - Options for setting speed\n * @param options.speed - The playback speed (0.5 to 2.0)\n * @returns A promise that resolves when the command is executed\n */\n setSpeed(options: { speed: number }): Promise<void>;\n\n /**\n * Set the current item in the playlist by index\n * @param options - Options for setting playlist item\n * @param options.index - The index of the item to play\n * @returns A promise that resolves when the command is executed\n */\n setPlaylistIndex(options: { index: number }): Promise<void>;\n\n /**\n * Load a playlist\n * @param options - Options for loading a playlist\n * @param options.playlistUrl - The URL of the playlist\n * @returns A promise that resolves when the command is executed\n */\n loadPlaylist(options: { playlistUrl: string }): Promise<void>;\n\n /**\n * Load a playlist with items\n * @param options - Options for loading a playlist\n * @param options.playlist - Array of playlist items\n * @returns A promise that resolves when the command is executed\n */\n loadPlaylistWithItems(options: { playlist: any[] }): Promise<void>;\n\n /**\n * Get available audio tracks\n * @returns A promise that resolves with available audio tracks\n */\n getAudioTracks(): Promise<{ tracks: any[] }>;\n\n /**\n * Get the current audio track\n * @returns A promise that resolves with current audio track index\n */\n getCurrentAudioTrack(): Promise<{ index: number }>;\n\n /**\n * Set the current audio track\n * @param options - Options for setting audio track\n * @param options.index - The index of the audio track\n * @returns A promise that resolves when the command is executed\n */\n setCurrentAudioTrack(options: { index: number }): Promise<void>;\n\n /**\n * Get the available captions/subtitles\n * @returns A promise that resolves with available captions\n */\n getCaptions(): Promise<{ captions: any[] }>;\n\n /**\n * Get the current captions/subtitles track\n * @returns A promise that resolves with current captions track index\n */\n getCurrentCaptions(): Promise<{ index: number }>;\n\n /**\n * Set the current captions/subtitles track\n * @param options - Options for setting captions track\n * @param options.index - The index of the captions track\n * @returns A promise that resolves when the command is executed\n */\n setCurrentCaptions(options: { index: number }): Promise<void>;\n\n /**\n * Get the current playlist\n * @returns A promise that resolves to the current playlist\n */\n currentPlaylist(): Promise<any>;\n}\n"]}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,KAAK,CAAC,UAAU,CAAC,OAA+B;QAC9C,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,KAAK,CAAC,UAAU,CAAC,OAA+B;QAC9C,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAA+D;QACxE,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAA0B;QACrC,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAA4B;QAC1C,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAA2B;QACxC,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAA2B;QAChD,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAiC;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,QAA6B;QACvD,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAA2B;QACpD,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA2B;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { JwPlayerPlugin } from './definitions';\n\nexport class JwPlayerWeb extends WebPlugin implements JwPlayerPlugin {\n async initialize(options: { licenseKey: string }): Promise<void> {\n console.log('INITIALIZE', options);\n return;\n }\n\n async play(_options: { mediaUrl: string; mediaType: 'video' | 'playlist' }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async pause(): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async stop(): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async seekTo(_options: { time: number }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async setVolume(_options: { volume: number }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async getPosition(): Promise<{ position: number }> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async getState(): Promise<{ state: number }> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async setSpeed(_options: { speed: number }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async setPlaylistIndex(_options: { index: number }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async loadPlaylist(_options: { playlistUrl: string }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async loadPlaylistWithItems(_options: { playlist: any[] }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async getAudioTracks(): Promise<{ tracks: any[] }> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async getCurrentAudioTrack(): Promise<{ index: number }> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async setCurrentAudioTrack(_options: { index: number }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async getCaptions(): Promise<{ captions: any[] }> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async getCurrentCaptions(): Promise<{ index: number }> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async setCurrentCaptions(_options: { index: number }): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async currentPlaylist(): Promise<any> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n\n async resume(): Promise<void> {\n throw this.unimplemented('JW Player is not available in web.');\n }\n}\n"]}
|
|
@@ -5,19 +5,19 @@ import Capacitor
|
|
|
5
5
|
@objc public func initialize(_ call: CAPPluginCall) -> String {
|
|
6
6
|
return "initialized"
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
@objc public func play(_ call: CAPPluginCall) -> String {
|
|
10
10
|
return "playing"
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
@objc public func pause(_ call: CAPPluginCall) -> String {
|
|
14
14
|
return "paused"
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
@objc public func stop(_ call: CAPPluginCall) -> String {
|
|
18
18
|
return "stopped"
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
@objc public func seekTo(_ call: CAPPluginCall) -> String {
|
|
22
22
|
return "seeked"
|
|
23
23
|
}
|