Skip to content

Commit

Permalink
Update OTSessionManager.java - Fix camera lifecycle (#654)
Browse files Browse the repository at this point in the history
* Update OTSessionManager.java

* Minor whitespace fixes and remove unused import

* Rev version to 2.25.1

---------

Co-authored-by: Jeff Swartz <[email protected]>
  • Loading branch information
cnx-carlosvogt and jeffswartz authored Jun 27, 2023
1 parent 54ae910 commit 737d059
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
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

0 comments on commit 737d059

Please sign in to comment.