Merge branch 'videocall_popup' of https://gitlab.com/Cloud_Solution/doctor_app_flutter into video-streaming-android

merge-requests/745/head
Mohammad Aljammal 4 years ago
commit ee7f8e9e42

@ -39,9 +39,15 @@
<subviews>
<view contentMode="scaleToFill" restorationIdentifier="VideoCallNavigationViewController" translatesAutoresizingMaskIntoConstraints="NO" id="eOT-Jr-GUl" userLabel="remoteVideo">
<rect key="frame" x="0.0" y="0.0" width="428" height="926"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" white="0.0" alpha="0.98999999999999999" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="O5s-CJ-RFv" userLabel="DragableBoundryDefiner">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="videoMutedIndicator" translatesAutoresizingMaskIntoConstraints="NO" id="CL1-2v-m1L" userLabel="remoteVideoMutedIndicator">
<rect key="frame" x="160.66666666666666" y="418.33333333333331" width="106.99999999999997" height="89.333333333333314"/>
<constraints>
<constraint firstAttribute="width" secondItem="CL1-2v-m1L" secondAttribute="height" multiplier="6:5" id="xqE-6Q-WAu"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="O5s-CJ-RFv">
<rect key="frame" x="0.0" y="100" width="428" height="731"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XHG-Db-3Px" customClass="AADraggableView" customModule="AADraggableView">
@ -100,20 +106,29 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4S7-45-trL">
<rect key="frame" x="0.0" y="0.0" width="428" height="731"/>
<connections>
<action selector="btnSwipeVideoTapped:" destination="t2c-G5-7AE" eventType="touchUpInside" id="7AQ-6d-4iR"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="4S7-45-trL" firstAttribute="leading" secondItem="O5s-CJ-RFv" secondAttribute="leading" id="AMe-9q-Xk9"/>
<constraint firstAttribute="trailing" secondItem="4S7-45-trL" secondAttribute="trailing" id="CX4-Rs-rep"/>
<constraint firstAttribute="trailing" secondItem="XHG-Db-3Px" secondAttribute="trailing" constant="10" id="Ncy-sD-qeL"/>
<constraint firstAttribute="bottom" secondItem="4S7-45-trL" secondAttribute="bottom" id="iJ9-pg-VXQ"/>
<constraint firstItem="XHG-Db-3Px" firstAttribute="top" secondItem="O5s-CJ-RFv" secondAttribute="top" constant="10" id="nM8-B7-soj"/>
<constraint firstItem="4S7-45-trL" firstAttribute="top" secondItem="O5s-CJ-RFv" secondAttribute="top" id="sNK-WK-tqV"/>
</constraints>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="videoMutedIndicator" translatesAutoresizingMaskIntoConstraints="NO" id="CL1-2v-m1L" userLabel="remoteVideoMutedIndicator">
<rect key="frame" x="154" y="413" width="120" height="100"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="eon-3Z-74P"/>
<constraint firstAttribute="height" constant="100" id="iyK-hL-H3m"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WPH-QE-Fvp">
<rect key="frame" x="0.0" y="0.0" width="428" height="926"/>
<connections>
<action selector="btnOnScreenTapped:" destination="t2c-G5-7AE" eventType="touchUpInside" id="jDS-QU-1VX"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sK0-tB-H9u" userLabel="controlButtons">
<rect key="frame" x="0.0" y="831" width="428" height="95"/>
<subviews>
@ -128,7 +143,7 @@
<state key="normal" title="Button" image="float_video"/>
<state key="selected" image="expand_video"/>
<connections>
<action selector="onMinimize:" destination="t2c-G5-7AE" eventType="touchUpInside" id="xul-cC-cbm"/>
<action selector="btnMinimizeTapped:" destination="t2c-G5-7AE" eventType="touchUpInside" id="xul-cC-cbm"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NUO-2p-pzL" userLabel="videoMuteButton">
@ -207,19 +222,20 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2nj-Va-L7c" userLabel="TopBar">
<rect key="frame" x="0.0" y="0.0" width="428" height="100"/>
<subviews>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="n8H-om-4LV">
<rect key="frame" x="393" y="75" width="25" height="25"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="n8H-om-4LV">
<rect key="frame" x="398" y="75" width="25" height="25"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="dyc-7x-bTk"/>
<constraint firstAttribute="width" constant="25" id="tYx-Ul-0Pf"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="60"/>
<state key="normal" image="hide_video_icon">
<color key="titleColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="●">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="hideVideoBtnTapped:" destination="t2c-G5-7AE" eventType="touchUpInside" id="2mC-ry-Lis"/>
<action selector="circleFloatBtnTapped:" destination="t2c-G5-7AE" eventType="touchUpInside" id="2mC-ry-Lis"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="bvC-Fa-s3m">
@ -261,7 +277,7 @@
<color key="backgroundColor" red="0.18431372549019609" green="0.1764705882352941" blue="0.16470588235294117" alpha="0.80000000000000004" colorSpace="custom" customColorSpace="displayP3"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="6eP-Zl-97q"/>
<constraint firstAttribute="trailing" secondItem="n8H-om-4LV" secondAttribute="trailing" constant="10" id="7Uq-4Q-ywD"/>
<constraint firstAttribute="trailing" secondItem="n8H-om-4LV" secondAttribute="trailing" constant="5" id="7Uq-4Q-ywD"/>
<constraint firstAttribute="bottom" secondItem="bvC-Fa-s3m" secondAttribute="bottom" priority="900" constant="5" id="HgY-Dw-B9R"/>
<constraint firstAttribute="bottom" secondItem="n8H-om-4LV" secondAttribute="bottom" id="Nr2-zL-avJ"/>
<constraint firstAttribute="bottom" secondItem="bvC-Fa-s3m" secondAttribute="bottom" constant="20" id="PWn-Sb-O8B"/>
@ -275,6 +291,7 @@
<constraints>
<constraint firstItem="eOT-Jr-GUl" firstAttribute="leading" secondItem="PoR-7r-yNe" secondAttribute="leading" id="4xz-lj-CXd"/>
<constraint firstAttribute="bottom" secondItem="eOT-Jr-GUl" secondAttribute="bottom" id="5Ae-F1-hSz"/>
<constraint firstItem="WPH-QE-Fvp" firstAttribute="leading" secondItem="PoR-7r-yNe" secondAttribute="leading" id="5Yr-p4-csA"/>
<constraint firstItem="2nj-Va-L7c" firstAttribute="leading" secondItem="PoR-7r-yNe" secondAttribute="leading" id="8Gx-Tb-bpo"/>
<constraint firstItem="O5s-CJ-RFv" firstAttribute="leading" secondItem="PoR-7r-yNe" secondAttribute="leading" id="Hyn-9r-k8s"/>
<constraint firstItem="sK0-tB-H9u" firstAttribute="leading" secondItem="PoR-7r-yNe" secondAttribute="leading" id="Itp-Pe-kh9"/>
@ -285,26 +302,33 @@
<constraint firstItem="CL1-2v-m1L" firstAttribute="centerY" secondItem="PoR-7r-yNe" secondAttribute="centerY" id="UGv-46-ri8"/>
<constraint firstAttribute="trailing" secondItem="O5s-CJ-RFv" secondAttribute="trailing" id="VcP-8e-3Un"/>
<constraint firstItem="CL1-2v-m1L" firstAttribute="centerX" secondItem="PoR-7r-yNe" secondAttribute="centerX" id="Xt8-k3-fDj"/>
<constraint firstItem="CL1-2v-m1L" firstAttribute="width" secondItem="PoR-7r-yNe" secondAttribute="width" multiplier="0.25" id="Yce-bz-JBd"/>
<constraint firstItem="WPH-QE-Fvp" firstAttribute="top" secondItem="PoR-7r-yNe" secondAttribute="top" id="ddA-LD-2O3"/>
<constraint firstItem="sK0-tB-H9u" firstAttribute="top" secondItem="O5s-CJ-RFv" secondAttribute="bottom" id="eOi-4p-iMm"/>
<constraint firstAttribute="trailing" secondItem="WPH-QE-Fvp" secondAttribute="trailing" id="evw-Oc-GgJ"/>
<constraint firstItem="O5s-CJ-RFv" firstAttribute="top" secondItem="2nj-Va-L7c" secondAttribute="bottom" id="fLH-dK-xpa"/>
<constraint firstItem="eOT-Jr-GUl" firstAttribute="top" secondItem="PoR-7r-yNe" secondAttribute="top" id="gFm-X8-RIU"/>
<constraint firstAttribute="trailing" secondItem="sK0-tB-H9u" secondAttribute="trailing" id="gSh-7K-3p5"/>
<constraint firstAttribute="bottom" secondItem="WPH-QE-Fvp" secondAttribute="bottom" id="sYs-wp-cot"/>
<constraint firstAttribute="trailing" secondItem="2nj-Va-L7c" secondAttribute="trailing" id="vQp-Bv-IVU"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="s5b-6P-Hwj"/>
<connections>
<outlet property="btnMinimize" destination="UZ6-EY-a59" id="bDC-LS-qlX"/>
<outlet property="btnScreenTap" destination="WPH-QE-Fvp" id="wiN-5a-WJO"/>
<outlet property="camSwitchBtn" destination="lar-xK-rhR" id="tde-s5-Mji"/>
<outlet property="controlButtons" destination="sK0-tB-H9u" id="mDK-cq-oQz"/>
<outlet property="draggableBoundryDefiner" destination="O5s-CJ-RFv" id="npi-81-C23"/>
<outlet property="fullVideoView" destination="eOT-Jr-GUl" id="VKE-el-YGR"/>
<outlet property="hideVideoBtn" destination="n8H-om-4LV" id="tTp-Ep-XKS"/>
<outlet property="lblCallDuration" destination="Btq-Ll-BPH" id="Jdh-yK-PEx"/>
<outlet property="lblRemoteUsername" destination="Zct-62-YE6" id="OQ0-mf-mvc"/>
<outlet property="localVideo" destination="0ZP-s2-kM5" id="C68-k7-h5j"/>
<outlet property="localVideoContainer" destination="O5s-CJ-RFv" id="bh9-Yr-UGv"/>
<outlet property="localVideoMutedBg" destination="6y1-an-W7F" id="5FF-Ak-Vxb"/>
<outlet property="micMuteBtn" destination="N2h-FX-kF5" id="zgK-g1-Ndr"/>
<outlet property="remoteVideo" destination="eOT-Jr-GUl" id="VKE-el-YGR"/>
<outlet property="remoteVideoMutedIndicator" destination="CL1-2v-m1L" id="aJ0-QC-m9Y"/>
<outlet property="smallVideoView" destination="0ZP-s2-kM5" id="C68-k7-h5j"/>
<outlet property="topBar" destination="2nj-Va-L7c" id="Zt4-J2-uw8"/>
<outlet property="videoMuteBtn" destination="NUO-2p-pzL" id="XCc-nu-N8P"/>
<outletCollection property="minimizeConstraint" destination="s8H-wK-WPB" collectionClass="NSMutableArray" id="XTM-jR-Cos"/>
<outletCollection property="minimizeConstraint" destination="HgY-Dw-B9R" collectionClass="NSMutableArray" id="Fi8-YX-9iQ"/>
@ -333,7 +357,6 @@
<image name="end_call" width="488" height="488"/>
<image name="expand_video" width="202" height="199"/>
<image name="float_video" width="202" height="202"/>
<image name="hide_video_icon" width="50" height="50"/>
<image name="mic_mute" width="198" height="199"/>
<image name="mic_unmute" width="198" height="202"/>
<image name="videoMutedIndicator" width="153.5" height="129"/>

@ -9,12 +9,19 @@ import AADraggableView
extension AADraggableView{
func enable(_ enable:Bool){
if enable == false{
isEnabled = enable
if enable == false{
gestureRecognizers?.forEach({ gest in
removeGestureRecognizer(gest)
})
}else{
isEnabled = true
}
}
}
extension UIView{
func hidden(_ hidden:Bool, rootView:UIView){
UIView.transition(with: rootView, duration: 0.5, options: .transitionCrossDissolve, animations: {
self.isHidden = hidden
})
}
}

@ -13,9 +13,10 @@ class MainAppViewController: FlutterViewController{
var videoCallContainer:AADraggableView!
var videoCallViewController:VideoCallViewController!
var videoCallFlutterResult:FlutterResult?
var vdoCallViewMinConstraint:[NSLayoutConstraint]!
var vdoCallViewMaxConstraint:[NSLayoutConstraint]!
var vdoCallViewFloatRectConstraint:[NSLayoutConstraint]!
var vdoCallViewFullConstraint:[NSLayoutConstraint]!
var vdoCallViewFloatCircleConstraint:[NSLayoutConstraint]!
override func viewDidLoad() {
super.viewDidLoad()
@ -58,22 +59,20 @@ extension MainAppViewController : ICallProtocol{
view.addSubview(videoCallContainer)
setVideoViewConstrints()
NSLayoutConstraint.activate(vdoCallViewMaxConstraint)
NSLayoutConstraint.deactivate(vdoCallViewMinConstraint)
NSLayoutConstraint.activate(vdoCallViewFullConstraint)
NSLayoutConstraint.deactivate(vdoCallViewFloatRectConstraint)
ViewEmbedder.embed(
withIdentifier: "videoCall", // Storyboard ID
parent: self,
container: self.videoCallContainer){ vc in
self.videoCallViewController = vc as? VideoCallViewController
}
}
private func showVideo(show:Bool){
UIView.transition(with: view, duration: 0.5, options: .transitionCrossDissolve, animations: {
self.videoCallContainer.isHidden = !show
})
self.videoCallContainer.hidden(!show, rootView: view)
}
private func startVideoCall(result: @escaping FlutterResult, call:FlutterMethodCall) {
@ -82,14 +81,19 @@ extension MainAppViewController : ICallProtocol{
if let arguments = call.arguments as? NSDictionary{
showVideoCallView(true)
videoCallViewController.onFloat = { min in
self.floatVideoCallView(min)
videoCallViewController.onRectFloat = { isRectFloat in
self.rectFloatVideoCallView(isRectFloat)
}
videoCallViewController.onCircleFloat = { isCircleFloat in
self.circleFloatVideoCallView(isCircleFloat)
}
videoCallViewController.onCallConnect = {
self.videoCallChannel?.invokeMethod("onCallConnected",arguments: nil)
}
videoCallViewController.onCallDisconnect = {
self.showVideoCallView(false)
self.videoCallViewController.minimizeVideoState(state: false)
self.videoCallChannel?.invokeMethod("onCallDisconnected",arguments: nil)
}
videoCallViewController.callBack = self
@ -99,16 +103,18 @@ extension MainAppViewController : ICallProtocol{
}
private func floatVideoCallView(_ value:Bool){
private func rectFloatVideoCallView(_ value:Bool){
videoCallContainer.enable(value)
UIView.animate(withDuration: 0.5) {
if(value){
NSLayoutConstraint.deactivate(self.vdoCallViewMaxConstraint)
NSLayoutConstraint.activate(self.vdoCallViewMinConstraint)
NSLayoutConstraint.deactivate(self.vdoCallViewFullConstraint)
NSLayoutConstraint.deactivate(self.vdoCallViewFloatCircleConstraint)
NSLayoutConstraint.activate(self.vdoCallViewFloatRectConstraint)
}else{
NSLayoutConstraint.deactivate(self.vdoCallViewMinConstraint)
NSLayoutConstraint.activate(self.vdoCallViewMaxConstraint)
NSLayoutConstraint.deactivate(self.vdoCallViewFloatRectConstraint)
NSLayoutConstraint.deactivate(self.vdoCallViewFloatCircleConstraint)
NSLayoutConstraint.activate(self.vdoCallViewFullConstraint)
}
self.videoCallContainer.layer.cornerRadius = value ? 10 : 0
self.videoCallContainer.layer.borderColor = value ? UIColor.white.cgColor : nil
@ -117,12 +123,32 @@ extension MainAppViewController : ICallProtocol{
}
}
private func showVideoCallView(_ value:Bool){
private func circleFloatVideoCallView(_ value:Bool){
videoCallContainer.reposition = value ? .sticky : .edgesOnly
UIView.animate(withDuration: 0.5) {
self.videoCallContainer.isHidden = !value
if(value){
NSLayoutConstraint.deactivate(self.vdoCallViewFullConstraint)
NSLayoutConstraint.deactivate(self.vdoCallViewFloatRectConstraint)
NSLayoutConstraint.activate(self.vdoCallViewFloatCircleConstraint)
self.videoCallContainer.layer.cornerRadius = 35
}else{
NSLayoutConstraint.activate(self.vdoCallViewFloatRectConstraint)
NSLayoutConstraint.deactivate(self.vdoCallViewFullConstraint)
NSLayoutConstraint.deactivate(self.vdoCallViewFloatCircleConstraint)
self.videoCallContainer.layer.cornerRadius = 10
}
self.videoCallContainer.layer.borderColor = value ? UIColor.white.cgColor : nil
self.videoCallContainer.layer.borderWidth = value ? 2 : 0
self.view.layoutIfNeeded()
}
}
private func showVideoCallView(_ value:Bool){
self.videoCallContainer.hidden(!value, rootView: view)
}
func sessionDone(res: Any) {
videoCallFlutterResult?(res)
}
@ -133,22 +159,32 @@ extension MainAppViewController : ICallProtocol{
func setVideoViewConstrints(){
videoCallContainer.layer.shadowColor = UIColor.black.cgColor
videoCallContainer.layer.shadowOffset = CGSize(width: 1, height: 1)
videoCallContainer.layer.shadowRadius = 5
let screen = UIScreen.main.bounds
videoCallContainer.translatesAutoresizingMaskIntoConstraints = false
vdoCallViewMinConstraint = [
videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
videoCallContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
videoCallContainer.widthAnchor.constraint(equalToConstant: screen.width/3),
videoCallContainer.heightAnchor.constraint(equalToConstant: screen.height/3.5)
]
vdoCallViewMaxConstraint = [
vdoCallViewFullConstraint = [
videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor),
videoCallContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor),
videoCallContainer.widthAnchor.constraint(equalToConstant: screen.width),
videoCallContainer.heightAnchor.constraint(equalToConstant: screen.height)
]
vdoCallViewFloatRectConstraint = [
videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor, constant: 40),
videoCallContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
videoCallContainer.widthAnchor.constraint(equalToConstant: screen.width/3),
videoCallContainer.heightAnchor.constraint(equalToConstant: screen.height/3.5)
]
vdoCallViewFloatCircleConstraint = [
videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor, constant: 40),
videoCallContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
videoCallContainer.widthAnchor.constraint(equalToConstant: 70),
videoCallContainer.heightAnchor.constraint(equalToConstant: 70)
]
}
}

@ -12,7 +12,8 @@ class VideoCallRequestParameters{
var generalId:String?
var doctorId:Int?
var baseUrl:String?
var patientName:String?
init(dictionary:NSDictionary){
self.apiKey = dictionary["kApiKey"] as? String
self.sessionId = dictionary["kSessionId"] as? String
@ -23,5 +24,6 @@ class VideoCallRequestParameters{
self.generalId = dictionary["generalId"] as? String
self.doctorId = dictionary["DoctorId"] as? Int
self.baseUrl = dictionary["baseUrl"] as? String
self.patientName = dictionary["patientName"] as? String
}
}

@ -34,8 +34,8 @@ class VideoCallViewController: UIViewController {
var seconds = 55
var isUserConnect : Bool = false
var onFloat:((Bool)->Void)? = nil
var onMinimize:(()->Void)? = nil
var onRectFloat:((Bool)->Void)? = nil
var onCircleFloat:((Bool)->Void)? = nil
var onCallConnect:(()->Void)? = nil
var onCallDisconnect:(()->Void)? = nil
@ -50,26 +50,55 @@ class VideoCallViewController: UIViewController {
@IBOutlet var minimizeConstraint: [NSLayoutConstraint]!
@IBOutlet var maximisedConstraint: [NSLayoutConstraint]!
@IBOutlet weak var btnMinimize: UIButton!
@IBOutlet weak var hideVideoBtn: UIButton!
@IBOutlet weak var draggableBoundryDefiner: UIView!
var localVideoDraggable:AADraggableView?
@IBOutlet weak var controlButtons: UIView!
@IBOutlet weak var remoteVideoMutedIndicator: UIImageView!
@IBOutlet weak var localVideoMutedBg: UIView!
@IBOutlet weak var btnScreenTap: UIButton!
@IBOutlet weak var localVideoContainer: UIView!
@IBOutlet weak var topBar: UIView!
@IBOutlet weak var lblCallDuration: UILabel!
@IBOutlet weak var remoteVideo: UIView!
@IBOutlet weak var localVideo: UIView!{
@IBOutlet weak var fullVideoView: UIView!
@IBOutlet weak var smallVideoView: UIView!{
didSet{
localVideo.layer.borderColor = UIColor.white.cgColor
localVideoDraggable = localVideo?.superview as? AADraggableView
smallVideoView.layer.borderColor = UIColor.white.cgColor
localVideoDraggable = smallVideoView?.superview as? AADraggableView
localVideoDraggable?.reposition = .edgesOnly
}
}
override func viewDidLoad() {
super.viewDidLoad()
localVideoDraggable?.respectedView = draggableBoundryDefiner
localVideoDraggable?.respectedView = localVideoContainer
}
@objc func click(gesture:UIGestureRecognizer){
gesture.view?.removeFromSuperview()
}
@IBAction func btnOnScreenTapped(_ sender: Any) {
if(hideVideoBtn.isSelected){
circleFloatBtnTapped(hideVideoBtn)
}else if(btnMinimize.isSelected){
btnMinimizeTapped(btnMinimize)
}
}
@IBAction func btnSwipeVideoTapped(_ sender: Any) {
// let smallVdoRender = smallVideoView.subviews.first
// let fullVdoRender = fullVideoView.subviews.first
// if let vdo = smallVdoRender{
// fullVideoView.addSubview(vdo)
// }
// if let vdo = fullVdoRender{
// smallVideoView.addSubview(vdo)
// }
//
// layoutVideoRenderViews()
}
@IBAction func didClickMuteButton(_ sender: UIButton) {
@ -77,10 +106,9 @@ class VideoCallViewController: UIViewController {
publisher!.publishAudio = !sender.isSelected
}
@IBAction func didClickSpeakerButton(_ sender: UIButton) {
@IBAction func didClickSpeakerButton(_ sender: UIButton) {
sender.isSelected = !sender.isSelected
subscriber?.subscribeToAudio = !sender.isSelected
// resetHideButtonsTimer()
}
@IBAction func didClickVideoMuteButton(_ sender: UIButton) {
@ -90,9 +118,8 @@ class VideoCallViewController: UIViewController {
} else {
publisher!.publishVideo = true
}
localVideo.isHidden = sender.isSelected
smallVideoView.isHidden = sender.isSelected
localVideoMutedBg.isHidden = !sender.isSelected
// resetHideButtonsTimer()
}
@ -104,7 +131,6 @@ class VideoCallViewController: UIViewController {
} else {
publisher!.cameraPosition = AVCaptureDevice.Position.back
}
/// resetHideButtonsTimer()
}
@IBAction func hangUp(_ sender: UIButton) {
@ -112,36 +138,46 @@ class VideoCallViewController: UIViewController {
sessionDisconnect()
}
@IBAction func hideVideoBtnTapped(_ sender: Any) {
onMinimize?()
@IBAction func circleFloatBtnTapped(_ sender: UIButton) {
sender.isSelected = !sender.isSelected
onCircleFloat?(sender.isSelected)
topBar.isHidden = sender.isSelected
controlButtons.isHidden = sender.isSelected
smallVideoView.isHidden = sender.isSelected
self.publisher?.view?.layoutIfNeeded()
}
var floated = false
@IBAction func onMinimize(_ sender: UIButton) {
floated = !floated
onFloat?(floated)
sender.isSelected = floated
@IBAction func btnMinimizeTapped(_ sender: UIButton) {
minimizeVideoState(state: !sender.isSelected)
btnScreenTap.isHidden = !sender.isSelected
}
func minimizeVideoState(state:Bool){
btnMinimize.isSelected = state
onRectFloat?(state)
NSLayoutConstraint.activate(floated ? minimizeConstraint : maximisedConstraint)
NSLayoutConstraint.deactivate(floated ? maximisedConstraint : minimizeConstraint)
localVideoDraggable?.enable(!floated)
NSLayoutConstraint.activate(state ? minimizeConstraint : maximisedConstraint)
NSLayoutConstraint.deactivate(state ? maximisedConstraint : minimizeConstraint)
localVideoDraggable?.enable(!state)
lblRemoteUsername.isHidden = floated
hideVideoBtn.isHidden = !floated
lblRemoteUsername.isHidden = state
hideVideoBtn.isHidden = !state
lblCallDuration.superview?.isHidden = !hideVideoBtn.isHidden
let min_ = floated
UIView.animate(withDuration: 0.5) {
self.videoMuteBtn.isHidden = min_
self.micMuteBtn.isHidden = min_
self.camSwitchBtn.isHidden = min_
let localVdoSize = self.localVideo.bounds.size
let remoteVdoSize = self.remoteVideo.bounds.size
self.publisher?.view?.frame = CGRect(x: 0, y: 0, width: localVdoSize.width, height: localVdoSize.height)
self.subscriber?.view?.frame = CGRect(x: 0, y: 0, width: remoteVdoSize.width, height: remoteVdoSize.height)
self.publisher?.view?.layoutIfNeeded()
self.subscriber?.view?.layoutIfNeeded()
self.videoMuteBtn.isHidden = state
self.micMuteBtn.isHidden = state
self.camSwitchBtn.isHidden = state
self.layoutVideoRenderViews()
}
}
func layoutVideoRenderViews(){
if let publisherVdoSize = publisher?.view?.superview?.bounds.size{
publisher?.view?.frame = CGRect(x: 0, y: 0, width: publisherVdoSize.width, height: publisherVdoSize.height)
}
if let subscriberVdoSize = subscriber?.view?.superview?.bounds.size{
subscriber?.view?.frame = CGRect(x: 0, y: 0, width: subscriberVdoSize.width, height: subscriberVdoSize.height)
}
}
@ -161,6 +197,9 @@ class VideoCallViewController: UIViewController {
}
func start(params:VideoCallRequestParameters){
lblRemoteUsername.text = params.patientName ?? "- - -"
btnScreenTap.isHidden = true
hideVideoBtn.isHidden = true
self.kApiKey = params.apiKey ?? ""
self.kSessionId = params.sessionId ?? ""
@ -171,11 +210,11 @@ class VideoCallViewController: UIViewController {
self.DoctorId = params.doctorId ?? 0
self.baseUrl = params.baseUrl ?? ""
setupButtons()
askForMicrophonePermission()
requestCameraPermissionsIfNeeded()
hideVideoMuted()
setupSession()
}
private func changeCallStatus(callStatus:Int){
@ -238,13 +277,6 @@ class VideoCallViewController: UIViewController {
}
}
func setupButtons() {
perform(#selector(hideControlButtons), with: nil, afterDelay: 3)
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(remoteVideoTapped(_:)))
view.addGestureRecognizer(tapGestureRecognizer)
view.isUserInteractionEnabled = true
}
// MARK: -Microphone Camera and Permission Request
func askForMicrophonePermission() {
@ -387,10 +419,11 @@ extension VideoCallViewController: OTSessionDelegate {
showAlert(error?.localizedDescription)
}
publisher?.view!.frame = CGRect(x: 0, y: 0, width: localVideo.bounds.size.width, height: localVideo.bounds.size.height)
publisher?.view?.tag = 11
publisher?.view?.layer.cornerRadius = 5
publisher?.view?.clipsToBounds = true
localVideo.addSubview((publisher?.view)!)
smallVideoView.addSubview((publisher?.view)!)
layoutVideoRenderViews()
}
func sessionDidDisconnect(_ session: OTSession) {
@ -430,9 +463,9 @@ extension VideoCallViewController: OTSessionDelegate {
guard let subscriberView = subscriber.view else {
return
}
subscriberView.frame = CGRect(x: 0, y: 0, width: remoteVideo.bounds.width, height: remoteVideo.bounds.height)
remoteVideo.addSubview(subscriberView)
subscriberView.tag = 22
fullVideoView.addSubview(subscriberView)
layoutVideoRenderViews()
startUpdateCallDuration()
onCallConnect?()
@ -481,12 +514,6 @@ extension VideoCallViewController: OTPublisherDelegate {
func publisher(_ publisher: OTPublisherKit, didFailWithError error: OTError) {
print("The publisher failed: \(error)")
}
@objc func remoteVideoTapped(_ recognizer: UITapGestureRecognizer?) {
if controlButtons.isHidden {
controlButtons.isHidden = false
perform(#selector(hideControlButtons), with: nil, afterDelay: 3)
}
}
}
extension VideoCallViewController: OTSubscriberDelegate {
@ -497,8 +524,5 @@ extension VideoCallViewController: OTSubscriberDelegate {
public func subscriber(_ subscriber: OTSubscriberKit, didFailWithError error: OTError) {
print("The subscriber failed to connect to the stream.")
}
@objc func hideControlButtons() {
// controlButtons.isHidden = true
}
}

Loading…
Cancel
Save