@capgo/capacitor-video-player 8.1.22 → 8.1.23

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.
@@ -1,3 +1,7 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- >
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <application>
3
+ <meta-data
4
+ android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
5
+ android:value="com.capgo.videoplayer.VideoPlayerCastOptionsProvider" />
6
+ </application>
3
7
  </manifest>
@@ -207,6 +207,10 @@ public class FullscreenExoPlayerFragment extends Fragment {
207
207
  private CastStateListener castStateListener = null;
208
208
  private Boolean playerReady = false;
209
209
 
210
+ private boolean isChromecastEnabled() {
211
+ return Boolean.TRUE.equals(chromecast);
212
+ }
213
+
210
214
  /**
211
215
  * Create Fragment View
212
216
  * @param inflater
@@ -254,7 +258,7 @@ public class FullscreenExoPlayerFragment extends Fragment {
254
258
  styledPlayerView.setUseController(true);
255
259
  }
256
260
 
257
- if (!chromecast) {
261
+ if (!isChromecastEnabled()) {
258
262
  mediaRouteButton.setVisibility(View.GONE);
259
263
  } else {
260
264
  initializeCastService();
@@ -708,7 +712,7 @@ public class FullscreenExoPlayerFragment extends Fragment {
708
712
 
709
713
  if (styledPlayerView != null) {
710
714
  // If cast is playing then it doesn't start the local player once get backs from background
711
- if (castContext != null && chromecast && castPlayer.isCastSessionAvailable()) return;
715
+ if (isChromecastEnabled() && castContext != null && castPlayer != null && castPlayer.isCastSessionAvailable()) return;
712
716
 
713
717
  initializePlayer();
714
718
  if (player.getCurrentPosition() != 0) {
@@ -746,7 +750,7 @@ public class FullscreenExoPlayerFragment extends Fragment {
746
750
  @Override
747
751
  public void onDestroy() {
748
752
  super.onDestroy();
749
- if (chromecast) mRouter.removeCallback(mCallback);
753
+ if (isChromecastEnabled() && mRouter != null) mRouter.removeCallback(mCallback);
750
754
  releasePlayer();
751
755
  }
752
756
 
@@ -756,7 +760,9 @@ public class FullscreenExoPlayerFragment extends Fragment {
756
760
  @Override
757
761
  public void onPause() {
758
762
  super.onPause();
759
- if (chromecast) castContext.removeCastStateListener(castStateListener);
763
+ if (isChromecastEnabled() && castContext != null && castStateListener != null) castContext.removeCastStateListener(
764
+ castStateListener
765
+ );
760
766
  boolean isAppBackground = false;
761
767
  if (bkModeEnabled) isAppBackground = isApplicationSentToBackground(context);
762
768
 
@@ -792,7 +798,7 @@ public class FullscreenExoPlayerFragment extends Fragment {
792
798
  player = null;
793
799
  showSystemUI();
794
800
  resetVariables();
795
- if (chromecast) {
801
+ if (isChromecastEnabled() && castPlayer != null) {
796
802
  castPlayer.release();
797
803
  castPlayer = null;
798
804
  }
@@ -1508,7 +1514,10 @@ public class FullscreenExoPlayerFragment extends Fragment {
1508
1514
  mRouter.addCallback(mSelector, mCallback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
1509
1515
  } else {
1510
1516
  Exception e = task.getException();
1511
- e.printStackTrace();
1517
+ Log.e(TAG, "Failed to initialize Chromecast", e);
1518
+ if (mediaRouteButton != null) {
1519
+ mediaRouteButton.setVisibility(View.GONE);
1520
+ }
1512
1521
  }
1513
1522
  }
1514
1523
  }
@@ -0,0 +1,26 @@
1
+ package com.capgo.videoplayer;
2
+
3
+ import android.content.Context;
4
+ import com.google.android.gms.cast.CastMediaControlIntent;
5
+ import com.google.android.gms.cast.framework.CastOptions;
6
+ import com.google.android.gms.cast.framework.OptionsProvider;
7
+ import com.google.android.gms.cast.framework.SessionProvider;
8
+ import com.google.android.gms.cast.framework.media.CastMediaOptions;
9
+ import com.google.android.gms.cast.framework.media.NotificationOptions;
10
+ import java.util.List;
11
+
12
+ public class VideoPlayerCastOptionsProvider implements OptionsProvider {
13
+
14
+ @Override
15
+ public CastOptions getCastOptions(Context context) {
16
+ return new CastOptions.Builder()
17
+ .setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
18
+ .setCastMediaOptions(new CastMediaOptions.Builder().setNotificationOptions(new NotificationOptions.Builder().build()).build())
19
+ .build();
20
+ }
21
+
22
+ @Override
23
+ public List<SessionProvider> getAdditionalSessionProviders(Context context) {
24
+ return null;
25
+ }
26
+ }
@@ -39,7 +39,7 @@ import java.util.Map;
39
39
  )
40
40
  public class VideoPlayerPlugin extends Plugin {
41
41
 
42
- private final String pluginVersion = "8.1.22";
42
+ private final String pluginVersion = "8.1.23";
43
43
 
44
44
  // Permission alias constants
45
45
  private static final String PERMISSION_DENIED_ERROR = "Unable to access media videos, user denied permission request";
@@ -8,7 +8,7 @@ import AVKit
8
8
  */
9
9
  @objc(VideoPlayerPlugin)
10
10
  public class VideoPlayerPlugin: CAPPlugin, CAPBridgedPlugin {
11
- private let pluginVersion: String = "8.1.22"
11
+ private let pluginVersion: String = "8.1.23"
12
12
  public let identifier = "VideoPlayerPlugin"
13
13
  public let jsName = "VideoPlayer"
14
14
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-video-player",
3
- "version": "8.1.22",
3
+ "version": "8.1.23",
4
4
  "description": "Capacitor plugin to play video in native player",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",