Skip to content

Commit

Permalink
chore: drm updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloocascio committed Nov 22, 2021
1 parent 7738fa0 commit 123c366
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.bitmovin.player.api.ui.FullscreenHandler;
import com.bitmovin.player.api.ui.StyleConfig;
import com.bitmovin.player.ui.CustomMessageHandler;
import com.bitmovin.player.ui.DefaultPictureInPictureHandler;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReadableMap;
Expand Down Expand Up @@ -60,7 +59,6 @@ public class ReactNativeBitmovinPlayerManager extends SimpleViewManager<PlayerVi
private final PlayerConfig playerConfig = new PlayerConfig();
private HashMap metaDataMap = new HashMap();
private boolean playerShouldPause = true;
private boolean isPictureInPictureMode = false;

@NotNull
@Override
Expand Down Expand Up @@ -348,10 +346,6 @@ public PlayerView createViewInstance(@NotNull ThemedReactContext context) {
_player = Player.create(context, playerConfig);
_playerView = new PlayerView(context, _player);
_playerView.setCustomMessageHandler(customMessageHandler);
// Create a PictureInPictureHandler and set it on the PlayerView
DefaultPictureInPictureHandler pictureInPictureHandler = new DefaultPictureInPictureHandler(context.getCurrentActivity(), _player);
_playerView.setPictureInPictureHandler(pictureInPictureHandler);

_fullscreen = false;
setListeners();
nextCallback = false;
Expand Down Expand Up @@ -441,9 +435,6 @@ public void setConfiguration(PlayerView view, ReadableMap config) {
String advisory;
boolean hasNextEpisode;

String licenseUrl = "https://5e712504-drm-widevine-licensing.axprod.net/AcquireLicense";
WidevineConfig wvConfig = new WidevineConfig(licenseUrl);

if (config != null && config.getString("url") != null) {

hasNextEpisode = config.getBoolean("hasNextEpisode");
Expand All @@ -456,8 +447,6 @@ public void setConfiguration(PlayerView view, ReadableMap config) {
Objects.requireNonNull(config.getString("url")),
SourceType.Dash
);
wvConfig.setHttpHeaders("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiYTZkNzNjMDItNjI4OC00N2I4LWEyYjktYTZkMDAxMjg4OGFjIiwiYmVnaW5fZGF0ZSI6IjIwMjEtMTAtMTNUMTc6NTE6MTEuNDUwNDg5WiIsImV4cGlyYXRpb25fZGF0ZSI6IjIwMjEtMTAtMTNUMTg6NTI6MTEuNDUwNDg5WiIsIm1lc3NhZ2UiOnsidHlwZSI6ImVudGl0bGVtZW50X21lc3NhZ2UiLCJ2ZXJzaW9uIjoyLCJsaWNlbnNlIjp7InN0YXJ0X2RhdGV0aW1lIjoiMjAyMS0wOC0wMlQwNTowMDowMFoiLCJleHBpcmF0aW9uX2RhdGV0aW1lIjoiMjAyMi0wOC0wMlQwNTowMDowMFoiLCJhbGxvd19wZXJzaXN0ZW5jZSI6dHJ1ZX0sImNvbnRlbnRfa2V5c19zb3VyY2UiOnsiaW5saW5lIjpbeyJpZCI6IjRDMUE2Qjk5ODc2RDQ5MUU4OTY1NzM4RDRGMTlBRjFEIiwiaXYiOiJ6UHFuMm1XcDJMQ3QrSWxrS0ovNTVnXHUwMDNkXHUwMDNkIiwiZW5jcnlwdGVkX2tleSI6IkxQZ2lNaG9uQ3hZQnAxWjZkcWVjTndcdTAwM2RcdTAwM2QifV19fX0.HlAZgnerJ4P3jwIRj9D8PMTeGhUsylVvZEeA2yAlAZ0");
sourceConfig.setDrmConfig(new WidevineConfig(licenseUrl));

if (config.getMap("advisory") != null) {
metaDataMap.put("hasNextEpisode", hasNextEpisode ? "true" : "false");
Expand Down Expand Up @@ -533,11 +522,7 @@ public void setChromecast(PlayerView view, Boolean hasChromecast) {
}

@Override
public void onResume() {
// Add the PictureInPictureEnterListener to the PlayerView
_playerView.onResume();

}
public void onResume() {}

@Override
public void onPause() {}
Expand Down Expand Up @@ -654,35 +639,6 @@ private void setListeners() {
"onRenderFirstFrame",
map);
});
_playerView.on(PlayerEvent.PictureInPictureAvailabilityChanged.class, event ->{
WritableMap map = Arguments.createMap();
map.putString("PiP Avalability", "true");

_reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
_playerView.getId(),
"onPiPAvailabilityChanged",
map);
});
_playerView.on(PlayerEvent.PictureInPictureEnter.class, event ->{
WritableMap map = Arguments.createMap();
map.putString("enterPiP", "true");

_reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
_playerView.getId(),
"onPiPEnter",
map);
});

_playerView.on(PlayerEvent.PictureInPictureExit.class, event ->{
WritableMap map = Arguments.createMap();
map.putString("exitPiP", "true");

_reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
_playerView.getId(),
"onPiPExit",
map);
});

_player.on(PlayerEvent.Error.class, event -> {
WritableMap map = Arguments.createMap();
WritableMap errorMap = Arguments.createMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,39 +102,6 @@ public void exitFullscreen(int tag) {
}
}

@ReactMethod
public void enterPiP(int tag) {
View playerView = getCurrentActivity().findViewById(tag);
if (playerView instanceof PlayerView) {
((PlayerView) playerView).enterPictureInPicture();
} else {
throw new ClassCastException(String.format("Cannot enterPictureInPicture: view with tag #%d is not a ReactNativeBitmovinPlayer", tag));
}
}

@ReactMethod
public void exitPiP(int tag) {
View playerView = getCurrentActivity().findViewById(tag);
if (playerView instanceof PlayerView) {
((PlayerView) playerView).exitPictureInPicture();
} else {
throw new ClassCastException(String.format("Cannot enterPictureInPicture: view with tag #%d is not a ReactNativeBitmovinPlayer", tag));
}
}

@ReactMethod
public void isPiPAvailable(int tag, Promise promise) {
View playerView = getCurrentActivity().findViewById(tag);

if (playerView instanceof PlayerView) {
boolean pipAvailable = ((PlayerView) playerView).isPictureInPictureAvailable();

promise.resolve(pipAvailable);
} else {
throw new ClassCastException(String.format("Cannot get isPiPAvailable: view with tag #%d is not a ReactNativeBitmovinPlayer", tag));
}
}

@ReactMethod
public void getCurrentTime(int tag, Promise promise) {
View playerView = getCurrentActivity().findViewById(tag);
Expand Down
1 change: 0 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:supportsPictureInPicture="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode|smallestScreenSize|screenLayout"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
Expand Down
3 changes: 0 additions & 3 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export default function App() {
onRewind={({ nativeEvent }) => {
console.log({ nativeEvent });
}}
onPiPEnter={({ nativeEvent }) => {
console.log({ nativeEvent });
}}
/>
);
}
Expand Down
25 changes: 0 additions & 25 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export type ReactNativeBitmovinPlayerMethodsType = {
destroy(): void;
seekBackwardCommand(): void;
seekForwardCommand(): void;
enterPiP(): void;
exitPiP(): void;
};

type ReactNativeBitmovinPlayerType = {
Expand Down Expand Up @@ -57,9 +55,6 @@ type ReactNativeBitmovinPlayerType = {
onFullscreenExit?: (event: any) => void;
onControlsShow?: (event: any) => void;
onControlsHide?: (event: any) => void;
onPiPAvailabilityChanged?: (event: any) => void;
onPiPEnter?: (event: any) => void;
onPiPExit?: (event: any) => void;
configuration: {
url: string;
poster?: string;
Expand Down Expand Up @@ -224,23 +219,6 @@ export default React.forwardRef<
);
};

const enterPiP = () => {
ReactNativeBitmovinPlayerModule.enterPiP(
findNodeHandle(playerRef.current || null)
);
};

const exitPiP = () => {
ReactNativeBitmovinPlayerModule.exitPiP(
findNodeHandle(playerRef.current || null)
);
};

const isPiPAvailable = () =>
ReactNativeBitmovinPlayerModule.isPiPAvailable(
findNodeHandle(playerRef.current || null)
);

const getCurrentTime = () =>
ReactNativeBitmovinPlayerModule.getCurrentTime(
findNodeHandle(playerRef.current || null)
Expand Down Expand Up @@ -296,9 +274,6 @@ export default React.forwardRef<
unmute,
enterFullscreen,
exitFullscreen,
enterPiP,
exitPiP,
isPiPAvailable,
getCurrentTime,
getDuration,
getVolume,
Expand Down

0 comments on commit 123c366

Please sign in to comment.