Skip to content

PLCameraStreamingSessionDelegate not called in swift #158

@danlniel

Description

@danlniel
let permissionBlock = {() -> Void in
            dispatch_async(self.sessionQueue!, {() -> Void in
                let videoCaptureConfiguration: PLVideoCaptureConfiguration = self.videoCaptureConfigurations!.last!
                let audioCaptureConfiguration: PLAudioCaptureConfiguration = PLAudioCaptureConfiguration.defaultConfiguration()
                // 视频编码配置
                let videoStreamingConfiguration: PLVideoStreamingConfiguration = self.videoStreamingConfigurations!.last!
                // 音频编码配置
                let audioStreamingConfiguration: PLAudioStreamingConfiguration = PLAudioStreamingConfiguration.defaultConfiguration()

                let orientation:AVCaptureVideoOrientation? = AVCaptureVideoOrientation(rawValue: UIDevice.currentDevice().orientation.rawValue)

                // 推流 session
                self.session = PLCameraStreamingSession(videoCaptureConfiguration: videoCaptureConfiguration, audioCaptureConfiguration: audioCaptureConfiguration, videoStreamingConfiguration: videoStreamingConfiguration, audioStreamingConfiguration: audioStreamingConfiguration, stream: stream, videoOrientation: orientation!)
                self.session!.delegate = self
                self.session!.bufferDelegate = self
                //            UIImage *waterMark = [UIImage imageNamed:@"qiniu.png"];
                //            [self.session setWaterMarkWithImage:waterMark position:CGPointMake(100, 300)];
                dispatch_async(dispatch_get_main_queue(), {() -> Void in
                    let previewView: UIView = self.session!.previewView
                    previewView.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
                    self.view!.insertSubview(previewView, atIndex: 0)
                    //                self.zoomSlider.minimumValue = 1;
                    //                self.zoomSlider.maximumValue = MIN(5, self.session.videoActiveFormat.videoMaxZoomFactor);
                    let log: String = String(format: "Zoom Range: [1..%.0f]", self.session!.videoActiveFormat.videoMaxZoomFactor)
                    print("\(log)")
                    //                self.textView.text = [NSString stringWithFormat:@"%@\%@", self.textView.text, log];
                    //                self.textView.text = [NSString stringWithFormat:@"%@\%@", self.textView.text, log];
                })
            })
            //        show countdown
//            self.performSelector(#selector(self.showCountdown), withObject: nil, afterDelay: 3.0)
        }
        let noAccessBlock = {() -> Void in
            Util.showAlertTitle(Constants.APP_NAME, message: "No Access")
        }
        switch PLCameraStreamingSession.cameraAuthorizationStatus() {
        case .Authorized:
            permissionBlock()
        case .NotDetermined:
            PLCameraStreamingSession.requestCameraAccessWithCompletionHandler({(granted: Bool) -> Void in
                granted ? permissionBlock() : noAccessBlock()
            })
        default:
            noAccessBlock()
        }

 func cameraStreamingSession(session: PLCameraStreamingSession!, streamStatusDidUpdate status: PLStreamStatus!) {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions