IOS9 Replaykit Recording Video

Source: Internet
Author: User

Monkey original, welcome reprint. Reproduced please specify: Reproduced from COCOS2DER-CSDN, thank you!
Original address: http://blog.csdn.net/cocos2der/article/details/50260873

IOS9 Replaykit video recording, API is easy, the following is the code, objective-c similar, will not write.

////Replaykitproxy.swift//Replaykitdemo////Created by Liuyanghui on 15/12/11.//Copyright 2015 Liuyanghui. All rights reserved.//ImportUIKitImportReplaykitclass Replaykitproxy:nsobject, Rppreviewviewcontrollerdelegate {Private varRootviewcontroller:uiviewcontroller?

Private varPreviewviewcontroller:rppreviewviewcontroller?Classvarsharedinstance:replaykitproxy {struct static {staticvaroncetoken:dispatch_once_t= 0StaticvarInstance:replaykitproxy? =Nil} dispatch_once (&Static.Oncetoken) {Static.Instance=Replaykitproxy () Static.Instance?.InitData ()}returnStatic.Instance!}PrivateFunc InitData () {}/// start recording videoFunc startrecording () { LetRecorder=Rpscreenrecorder.Sharedrecorder ()ifRecorder.Available== false{Print ("Replaykit is not available")return}ifRecorder.Recording== true{Print ("Replaykit is recording")return} Recorder.Startrecordingwithmicrophoneenabled (true) {(Error) -Void inch ifError!=Nil {print (Error?.localizeddescription)}}}/// stop recording videoFunc stoprecording () { LetRecorder=Rpscreenrecorder.Sharedrecorder ()ifRecorder.Recording== false{return} Recorder.Stoprecordingwithhandler {(Previewviewcontroller, error) -Void inch ifError!=Nil {print (Error?

.Localizeddescription)}Else if LetViewcontroller=previewviewcontroller{Viewcontroller.Previewcontrollerdelegate= Self Self.Previewviewcontroller=Viewcontroller}}}/// Delete recorded video, must be called after stoprecordingFunc discardrecording () { LetRecorder=Rpscreenrecorder.Sharedrecorder ()ifRecorder.Recording== true{return} Recorder.Discardrecordingwithhandler {() -Void inchPrint"discardrecording Complete") } }/// display videoFunc displayrecordingcontent () {//ipad needs to change display mode, otherwise it may cause Sorceview to nil exception ifUidevice.Currentdevice ().Userinterfaceidiom==Uiuserinterfaceidiom.Pad { Self.Previewviewcontroller?.Modalpresentationstyle=Uimodalpresentationstyle.CurrentContext Self.Previewviewcontroller?.Popoverpresentationcontroller?.Sourceview= Self.Rootviewcontroller?.View} Rootviewcontroller?.Presentviewcontroller ( Self.Previewviewcontroller!, Animated:true, completion: {() -Void inchPrint"Display Complete") }) }//MARK:-DelegateFunc Previewcontrollerdidfinish (previewcontroller:rppreviewviewcontroller) {Previewcontroller.Dismissviewcontrolleranimated (true) { () -Void inch} }}

IOS9 Replaykit Recording Video

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.