Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OTSessionManager.java - Fix camera lifecycle #654

Merged
merged 5 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.25.1 (June 27 2023)

- [Fix]: Fix camera lifecycle on Android. - issue #645

# 2.25.0 (May 17 2023)

- [Update]: Update OpenTok Android SDK and OpenTok iOS SDK to version 2.25.1.
Expand Down
35 changes: 33 additions & 2 deletions android/src/main/java/com/opentokreactnative/OTSessionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
* Created by manik on 1/29/18.
*/

import android.os.Build;
import android.util.Log;
import android.widget.FrameLayout;
import android.view.View;

import androidx.annotation.Nullable;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Expand Down Expand Up @@ -56,7 +57,9 @@ public class OTSessionManager extends ReactContextBaseJavaModule
SubscriberKit.AudioStatsListener,
SubscriberKit.VideoStatsListener,
SubscriberKit.VideoListener,
SubscriberKit.StreamListener{
SubscriberKit.StreamListener,
LifecycleEventListener
{

private ConcurrentHashMap<String, Integer> connectionStatusMap = new ConcurrentHashMap<>();
private ArrayList<String> jsEvents = new ArrayList<String>();
Expand All @@ -72,6 +75,7 @@ public OTSessionManager(ReactApplicationContext reactContext) {

super(reactContext);
sharedState = OTRN.getSharedState();
reactContext.addLifecycleEventListener(this);
}

@ReactMethod
Expand Down Expand Up @@ -981,5 +985,32 @@ public void onStreamVideoTypeChanged(Session session, Stream stream, Stream.Stre
sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamPropertyChanged", eventData);
printLogs("onStreamVideoTypeChanged");
}
@Override
public void onHostResume() {
ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();

for (String key: mPublishers.keySet()) {
Publisher publisher = mPublishers.get(key);

if (publisher != null) {
publisher.onResume();
}
}
}

@Override
public void onHostPause() {
ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();

for (String key: mPublishers.keySet()) {
Publisher publisher = mPublishers.get(key);

if (publisher != null) {
publisher.onPause();
}
}
}
@Override
public void onHostDestroy() {}

}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opentok-react-native",
"version": "2.25.0",
"version": "2.25.1",
"description": "React Native components for OpenTok iOS and Android SDKs",
"main": "src/index.js",
"homepage": "https://www.tokbox.com",
Expand Down