use of com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable in project capacitor-video-player by jepiqueau.
the class CapacitorVideoPlayerPlugin method AddObserversToNotificationCenter.
private void AddObserversToNotificationCenter() {
NotificationCenter.defaultCenter().addMethodForNotification("playerItemPlay", new MyRunnable() {
@Override
public void run() {
JSObject data = new JSObject();
data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
data.put("currentTime", this.getInfo().get("currentTime"));
notifyListeners("jeepCapVideoPlayerPlay", data);
return;
}
});
NotificationCenter.defaultCenter().addMethodForNotification("playerItemPause", new MyRunnable() {
@Override
public void run() {
JSObject data = new JSObject();
data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
data.put("currentTime", this.getInfo().get("currentTime"));
notifyListeners("jeepCapVideoPlayerPause", data);
return;
}
});
NotificationCenter.defaultCenter().addMethodForNotification("playerItemReady", new MyRunnable() {
@Override
public void run() {
JSObject data = new JSObject();
data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
data.put("currentTime", this.getInfo().get("currentTime"));
notifyListeners("jeepCapVideoPlayerReady", data);
return;
}
});
NotificationCenter.defaultCenter().addMethodForNotification("playerItemEnd", new MyRunnable() {
@Override
public void run() {
final JSObject data = new JSObject();
data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
data.put("currentTime", this.getInfo().get("currentTime"));
bridge.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
FrameLayout frameLayoutView = getBridge().getActivity().findViewById(frameLayoutViewId);
if (frameLayoutView != null) {
((ViewGroup) getBridge().getWebView().getParent()).removeView(frameLayoutView);
fragmentUtils.removeFragment(fsFragment);
}
fsFragment = null;
NotificationCenter.defaultCenter().removeAllNotifications();
notifyListeners("jeepCapVideoPlayerEnded", data);
}
});
}
});
NotificationCenter.defaultCenter().addMethodForNotification("playerFullscreenDismiss", new MyRunnable() {
@Override
public void run() {
boolean ret = false;
final JSObject data = new JSObject();
if (Integer.valueOf((String) this.getInfo().get("dismiss")) == 1)
ret = true;
data.put("dismiss", ret);
bridge.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
FrameLayout frameLayoutView = getBridge().getActivity().findViewById(frameLayoutViewId);
if (frameLayoutView != null) {
((ViewGroup) getBridge().getWebView().getParent()).removeView(frameLayoutView);
fragmentUtils.removeFragment(fsFragment);
}
fsFragment = null;
NotificationCenter.defaultCenter().removeAllNotifications();
notifyListeners("jeepCapVideoPlayerExit", data);
}
});
}
});
NotificationCenter.defaultCenter().addMethodForNotification("videoPathInternalReady", new MyRunnable() {
@Override
public void run() {
long videoId = (Long) this.getInfo().get("videoId");
// Get the previously saved call
FrameLayout pickerLayoutView = getBridge().getActivity().findViewById(pickerLayoutViewId);
if (pickerLayoutView != null) {
((ViewGroup) getBridge().getWebView().getParent()).removeView(pickerLayoutView);
fragmentUtils.removeFragment(pkFragment);
}
pkFragment = null;
if (videoId != -1) {
createFullScreenFragment(call, videoPath, videoRate, exitOnEnd, loopOnEnd, pipEnabled, null, null, null, isTV, fsPlayerId, true, videoId);
} else {
Toast.makeText(context, "No Video files found ", Toast.LENGTH_SHORT).show();
Map<String, Object> info = new HashMap<String, Object>() {
{
put("dismiss", "1");
}
};
NotificationCenter.defaultCenter().postNotification("playerFullscreenDismiss", info);
}
}
});
}
Aggregations