VPCamera3/SwiftProject/SwiftProject/Project/Controller/CCHomeController.swift
2024-04-12 18:02:36 +08:00

667 lines
28 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// CCHomeController.swift
// SwiftProject
//
// Created by soldoros on 2024/1/10.
//
import CoreImage
import Foundation
//import Observation
import VideoToolbox
import AVFoundation
import MetalKit
//import Cocoa
import SwiftUI
import CoreImage
import Foundation
//import Observation
import VideoToolbox
import AVKit
import CoreMedia
import LLCycleScrollView
import TZImagePickerController
import MessageUI
import SVProgressHUD
import Firebase
import AdSupport
class CCHomeController: BaseController, LLCycleScrollViewDelegate,MFMailComposeViewControllerDelegate {
var heroAsset:AVAsset?
var mTopImgView:UIImageView?
var mBottomImgView:UIImageView?
var mTopCenterBtn:UIButton?
var cycleScrollView:LLCycleScrollView?
var mCenLab1:UILabel?
var mCenLab2:UILabel?
var mBottomView:UIView?
var mBottomBtn1:UIButton?
var mBottomBtn2:UIButton?
var mBottomBtn3:UIButton?
var mineView:CCMineView?
// var mTopView:UIView?
var mBackView:UIView?
var selectedAssets:[Any] = []
var maxImages:NSInteger = 10
let kNowTimeToUserDefaultKey_Home:String = "kNowTimeToUserDefaultKey_Home"
lazy var spaceAlbumPopView: CCSpaceAlbumFilterPopView2 = {
let view = CCSpaceAlbumFilterPopView2.init(frame: CGRectMake(0, 0, KScreenWidth, KScreenHeight))
return view
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.tabBarController!.tabBar.isHidden = true;
self.navigationController?.tabBarController!.tabBar.isTranslucent = true;
self.setNavgationBarColor(color: UIColor.clear)
self.checkAirPlayStatus()
}
override func viewDidLoad() {
super.viewDidLoad()
uploadAppInfo()
ZZHHelper.setNowTimeToUserDefaultWithKey(kNowTimeToUserDefaultKey_Home)
self.view.backgroundColor = UIColor.black
self.navLine?.isHidden = true
// AirPlay
NotificationCenter.default.addObserver(self, selector: #selector(airPlayStatusDidChange(_:)), name: AVAudioSession.routeChangeNotification, object: nil)
//393*236
mTopImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: SCREEN_Width, height: SCREEN_Height * 236/393))
view.addSubview(mTopImgView!)
mTopImgView?.image = UIImage.init(named: "BG_Top")
self.view.bringSubviewToFront(self.navtionBar!)
//393*240
mBottomImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: SCREEN_Width, height: SCREEN_Height * 240/393))
mBottomImgView!.bottom = SCREEN_Height
view.addSubview(mBottomImgView!)
mBottomImgView?.image = UIImage.init(named: "BG_Bottom_Light")
//76*56
leftBtn1 = UIButton.init(type: UIButton.ButtonType.custom)
navtionBar?.addSubview(leftBtn1!)
leftBtn1?.tag = 11
leftBtn1?.isSelected = false
leftBtn1?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside)
let img:UIImage = UIImage.init(named: "Icon_Menu" as String)!
leftBtn1?.setImage(img, for: UIControl.State.normal)
leftBtn1?.frame = CGRect(x: 5, y: 10, width: 76, height: 56)
leftBtn1!.centerY = StatuBar_Height + NavBar_Height * 0.5
//76*56
rightBtn1 = UIButton.init(type: UIButton.ButtonType.custom)
navtionBar?.addSubview(rightBtn1!)
rightBtn1?.tag = 10
rightBtn1?.isSelected = false
rightBtn1?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside)
let img2:UIImage = UIImage.init(named: "vip_Diamond" as String)!
rightBtn1?.setImage(img2, for: UIControl.State.normal)
rightBtn1?.frame = CGRect(x: 2, y: 10, width: 76, height: 56)
rightBtn1!.centerY = StatuBar_Height + NavBar_Height * 0.5
rightBtn1!.right = SCREEN_Width
//173*36
mTopCenterBtn = UIButton.init(type: UIButton.ButtonType.custom)
navtionBar?.addSubview(mTopCenterBtn!)
mTopCenterBtn!.backgroundColor = UIColor.hexStringToColor(hexString: "#060507")
mTopCenterBtn?.tag = 12
mTopCenterBtn?.isSelected = false
mTopCenterBtn?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside)
mTopCenterBtn?.frame = CGRect(x: 2, y: 10, width: SCREEN_Width * 0.4, height: 36)
mTopCenterBtn!.centerY = StatuBar_Height + NavBar_Height * 0.5
mTopCenterBtn!.centerX = SCREEN_Width * 0.5
mTopCenterBtn!.clipsToBounds = true
mTopCenterBtn!.layer.cornerRadius = mTopCenterBtn!.height * 0.5
mTopCenterBtn!.layer.borderWidth = 0.5
mTopCenterBtn!.layer.borderColor = UIColor.white.cgColor
mTopCenterBtn!.setTitle(NSLocalizedString("未连接VR设备", comment: ""), for: UIControl.State.normal)
mTopCenterBtn!.setTitleColor(UIColor.white, for: UIControl.State.normal)
mTopCenterBtn!.titleLabel?.font = UIFont.systemFont(ofSize: 12)
mTopCenterBtn!.isEnabled = false
centerView()
bottomButton()
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
let sec:TimeInterval = ZZHHelper.getSecFromUserDefaultByKey(kNowTimeToUserDefaultKey_Home)
Analytics.logEvent("home_pv", parameters: ["refer_page":"首页","duration":sec])
}
//MARK: - ---
func uploadAppInfo() {
ZNetUtil.postUrl(urlStr: ZNetUtil.kUploadAppInfoUrl, params: ["eventName":"app_open"]) { result, error in
print("上报回调...")
}
if ZZHHelper.checkAppIsFirstlanuch() {
ZNetUtil.postUrl(urlStr: ZNetUtil.kUploadAppInfoUrl, params: ["eventName":"first_open"]) { result, error in
print("上报回调...")
}
}
}
//MARK: -
@objc private func airPlayStatusDidChange(_ notification: Notification) {
checkAirPlayStatus()
}
private func checkAirPlayStatus() {
print("设备连接变化 homecontroller")
let currentRoute = AVAudioSession.sharedInstance().currentRoute
let isAirPlayActive = currentRoute.outputs.contains { output in
return output.portType == AVAudioSession.Port.HDMI ||
output.portType == AVAudioSession.Port.airPlay
}
mTopCenterBtn!.setTitle((isAirPlayActive ? NSLocalizedString("已连接外部设备", comment: "") : NSLocalizedString("未连接VR设备", comment: "")), for: UIControl.State.normal)
mTopCenterBtn!.backgroundColor = isAirPlayActive ? UIColor.colorWithRGBINT(_r: 73, _g: 34, _b: 208) : UIColor.hexStringToColor(hexString: "#060507")
isAirPlayActive ? mTopCenterBtn!.setImage(UIImage.init(named: "linked_button"), for: .normal) : mTopCenterBtn!.setImage(nil,for: .normal)
isAirPlayActive ? mTopCenterBtn!.updateBtnEdgeInsets(style: .Left, space: 5):mTopCenterBtn!.updateBtnEdgeInsets(style: .Left, space: 0)
}
func centerView(){
//345*200
cycleScrollView = LLCycleScrollView()
cycleScrollView?.frame = CGRect.init(x: 24, y: Int(SafeAreaTop_Height) + 35, width: Int(SCREEN_Width)-48 , height: (Int(SCREEN_Width) - 48) * 200/345)
cycleScrollView!.delegate = self
//
cycleScrollView!.autoScroll = true
// 😄
cycleScrollView!.infiniteLoop = true
// (2)
cycleScrollView!.autoScrollTimeInterval = 3.0
//
cycleScrollView!.placeHolderImage = UIImage(named: "Banner_01")
// 使
cycleScrollView!.coverImage = UIImage(named: "Banner_01")
// =UIImageViewContentMode
cycleScrollView!.imageViewContentMode = .scaleToFill
// vertical || horizontal
cycleScrollView!.scrollDirection = .horizontal
// PageControl (.none, .system, .fill, .pill, .snake)
cycleScrollView!.customPageControlStyle = .snake
// .systemPageControltintColor
cycleScrollView!.customPageControlInActiveTintColor = UIColor.hexStringToColor(hexString: "#555555")
// .systemUIPageControl
cycleScrollView!.pageControlCurrentPageColor = UIColor.white
// .systemPageControl(8.0)
cycleScrollView!.customPageControlIndicatorPadding = 8.0
// PageControl (.left, .right .center)
cycleScrollView!.pageControlPosition = .center
cycleScrollView!.pageControlBottom = -130
// view
self.view.addSubview(cycleScrollView!)
//
cycleScrollView!.imagePaths = ["Banner_01","Banner_02","Banner_03"]
mCenLab1 = UILabel()
mCenLab1!.bounds = CGRect(x: 0, y: 0, width: SCREEN_Width - 30, height: 0)
mCenLab1!.textColor = UIColor.white
mCenLab1!.font = UIFont.boldSystemFont(ofSize: 18)
self.view.addSubview(mCenLab1!)
mCenLab1!.text = NSLocalizedString("Tips.1 拍摄空间照片以及视频", comment: "")
mCenLab1!.sizeToFit()
mCenLab1!.top = cycleScrollView!.bottom + 32
mCenLab1!.centerX = SCREEN_Width * 0.5
mCenLab2 = UILabel()
mCenLab2!.numberOfLines = 3
mCenLab2!.textAlignment = NSTextAlignment.center
mCenLab2!.bounds = CGRect(x: 0, y: 0, width: SCREEN_Width - 30, height: 0)
mCenLab2!.textColor = UIColor.hexStringToColor(hexString: "#CDCDCD")
mCenLab2!.font = UIFont.systemFont(ofSize: 14)
self.view.addSubview(mCenLab2!)
mCenLab2!.text = NSLocalizedString("一键拍摄空间格式的照片以及视频,留住美好瞬间", comment: "")
mCenLab2!.sizeToFit()
mCenLab2!.top = mCenLab1!.bottom + 16
mCenLab2!.centerX = SCREEN_Width * 0.5
}
//
func cycleScrollView(_ cycleScrollView: LLCycleScrollView, scrollTo index: NSInteger) {
// print("\(index)")
let arr1 = [NSLocalizedString("Tips.1 拍摄空间照片以及视频", comment: ""),NSLocalizedString("Tips.2 视频转码", comment: ""),NSLocalizedString("Tips.3 直连VR设备", comment: "")]
let arr2 = [NSLocalizedString("一键拍摄空间格式的照片以及视频,留住美好瞬间", comment: ""),
NSLocalizedString("可以将任意格式视频转码为 VR 或 3D 格式", comment: ""),
NSLocalizedString("可以通过链接VR设备直接观看转码内容", comment: "")]
DispatchQueue.main.async { [weak self] in
self!.mCenLab1!.width = SCREEN_Width - 30
self!.mCenLab1!.text = arr1[index]
self!.mCenLab1!.sizeToFit()
self!.mCenLab1!.top = self!.cycleScrollView!.bottom + 32
self!.mCenLab1!.centerX = SCREEN_Width * 0.5
self!.mCenLab2!.width = SCREEN_Width - 30
self!.mCenLab2!.text = arr2[index]
self!.mCenLab2!.sizeToFit()
self!.mCenLab2!.top = self!.mCenLab1!.bottom + 16
self!.mCenLab2!.centerX = SCREEN_Width * 0.5
}
}
func cycleScrollView(_ cycleScrollView: LLCycleScrollView, didSelectItemIndex index: NSInteger) {
print("用户点击了第\(index)个页面")
}
func bottomButton(){
let wd1 = (SCREEN_Width - 58)/2
let hi1 = wd1 * 80/167
let hi2 = wd1 * 172/167
//167*80
mBottomBtn1 = UIButton.init(type: UIButton.ButtonType.custom)
self.view.addSubview(mBottomBtn1!)
mBottomBtn1?.tag = 20
mBottomBtn1?.isSelected = false
mBottomBtn1?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside)
mBottomBtn1?.frame = CGRect(x: 24, y: 10, width: wd1, height: hi1)
mBottomBtn1!.bottom = SCREEN_Height - SafeAreaBottom_Height - 200
mBottomBtn1!.titleLabel?.font = UIFont.systemFont(ofSize: 12)
mBottomBtn1?.setBackgroundImage(UIImage.init(named: NSLocalizedString("home_card", comment: "")), for: UIControl.State.normal)
mBottomBtn2 = UIButton.init(type: UIButton.ButtonType.custom)
self.view.addSubview(mBottomBtn2!)
mBottomBtn2?.tag = 21
mBottomBtn2?.isSelected = false
mBottomBtn2?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside)
mBottomBtn2?.frame = CGRect(x: 24, y: 10, width: wd1, height: hi1)
mBottomBtn2!.top = mBottomBtn1!.bottom + 12
mBottomBtn2!.titleLabel?.font = UIFont.systemFont(ofSize: 12)
mBottomBtn2?.setBackgroundImage(UIImage.init(named: NSLocalizedString("home_card_1", comment: "")), for: UIControl.State.normal)
mBottomBtn3 = UIButton.init(type: UIButton.ButtonType.custom)
self.view.addSubview(mBottomBtn3!)
mBottomBtn3?.tag = 22
mBottomBtn3?.isSelected = false
mBottomBtn3?.addTarget(self, action: #selector(navgationButtonClick2(sender:)), for: UIControl.Event.touchUpInside)
mBottomBtn3?.frame = CGRect(x: 24, y: mBottomBtn1!.top, width: wd1, height: hi2)
mBottomBtn3!.left = mBottomBtn1!.right + 10
mBottomBtn3!.titleLabel?.font = UIFont.systemFont(ofSize: 12)
mBottomBtn3?.setBackgroundImage(UIImage.init(named: NSLocalizedString("home_card_2", comment: "")), for: UIControl.State.normal)
}
//MARK: -
@objc public func navgationButtonClick2(sender:UIButton){
print("nihao")
//
if(sender.tag == 11){
addMenu()
}
if(sender.tag == 10) {//
let vc:MembershipVC = MembershipVC()
let nav = UINavigationController(rootViewController: vc)
nav.modalTransitionStyle = UIModalTransitionStyle.coverVertical
nav.modalPresentationStyle = .fullScreen
self.present(nav, animated: true)
if !UserInfo.sharedInstance.isMemberShip {//
Analytics.logEvent("home_unvip_click", parameters: nil)
}
}
if sender.tag == 20 {
// if UserInfo.sharedInstance.isMemberShip {
let vc:CCSpatialShootController = CCSpatialShootController()
self.navigationController?.pushViewController(vc, animated: true)
// }
// else {
// }
}else if sender.tag == 21{
//
// gotoSpatialPlayVC()
// CCBottomMenuPopView.share.show(imageNameArray: ["Icon_PopUp_Icon_Scenes","Icon_PopUp_Icon_Photo","Icon_PopUp_Icon_Folder"], textArray: ["簿","",""]) { index in
CCBottomMenuPopView.share.show(imageNameArray: ["Icon_PopUp_Icon_Scenes","Icon_PopUp_Icon_Photo"], textArray: [NSLocalizedString("空间相簿", comment: ""),NSLocalizedString("照片图库", comment: "")]) { index in
if index == 0 {
self.spaceAlbum()
}else if index == 1 {
self.photoLibrary()
}
}
}else if sender.tag == 22 {
//VR
let view = CCSpaceAlbumFilterPopView2.init(frame: CGRectMake(0, 0, KScreenWidth, KScreenHeight))
self.view.addSubview(view)
view.show()
//
view.selectedImageHandler = { [weak self] data,asset in
print("回调")
let vc = CCSpatialPhotoDisplayController()
vc.photoOriginalData = data
vc.imageAsset = asset
self?.navigationController?.pushViewController(vc, animated: true)
}
//
view.selectedVideoHandler = {[weak self] url,asset in
if (asset.duration > 60 ) {
if !UserInfo.sharedInstance.isMemberShip {
let vc:MembershipVC = MembershipVC()
let nav = UINavigationController(rootViewController: vc)
nav.modalTransitionStyle = UIModalTransitionStyle.coverVertical
nav.modalPresentationStyle = .fullScreen
self?.present(nav, animated: true)
return
}
}
let vc = CCSpatialVideoDisplayController()
vc.sourceVideoURL = url
vc.videoOriginalPHAsset = asset
self?.navigationController?.pushViewController(vc, animated: true)
}
}
}
func addMenu(){
let vc = MenuVC()
self.navigationController?.pushViewController(vc, animated: true)
return
mBackView = UIView(frame: self.view.bounds)
mBackView!.backgroundColor = UIColor.colorWithRGB(_r: 0, _g: 0, _b: 0, alpha: 0.01)
self.view.addSubview(mBackView!)
// mTopView = UIView(frame: CGRect(x: 0, y: -StatuBar_Height, width: SCREEN_Width, height: StatuBar_Height))
// mTopView?.backgroundColor = UIColor.hexStringToColor(hexString: "#2C2737")
// self.view.addSubview(mTopView!)
let tap:UITapGestureRecognizer = UITapGestureRecognizer.init(target: self, action: #selector(tapsender(sender:)))
mBackView!.addGestureRecognizer(tap)
mineView = CCMineView(frame: CGRect.init(x: -SCREEN_Width, y: 0, width: SCREEN_Width-108, height: SCREEN_Height))
self.view.addSubview(mineView!)
mineView!.handle = {dic in
print(dic["name"] as Any)
if((dic["name"] as! String).elementsEqual(NSLocalizedString("隐私政策", comment: ""))){
let vc:CCWebController = CCWebController()
vc.titleValue = NSLocalizedString("隐私政策", comment: "")
let sizeUrl = NSLocalizedString("siteUrl", comment: "隐私政策url")
vc.urlString = sizeUrl
self.navigationController?.pushViewController(vc, animated: true)
}
else if((dic["name"] as! String).elementsEqual(NSLocalizedString("用户协议", comment: ""))){
let vc:CCWebController = CCWebController()
vc.titleValue = NSLocalizedString("用户协议", comment: "")
let sizeUrl = NSLocalizedString("userSiteUrl", comment: "用户协议url")
vc.urlString = sizeUrl
self.navigationController?.pushViewController(vc, animated: true)
}
else if((dic["name"] as! String).elementsEqual(NSLocalizedString("联系我们", comment: ""))) {//
if !MFMailComposeViewController.canSendMail() {
SVProgressHUD.showInfo(withStatus: NSLocalizedString("请先前往系统设置配置发送的邮箱信息", comment: ""))
return
}
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.mailComposeDelegate = self
mailComposeViewController.setSubject("")
mailComposeViewController.setMessageBody(NSLocalizedString("请在此处描述您需要反馈的问题.", comment: ""), isHTML: false)
mailComposeViewController.setToRecipients(["fangaoqdi@163.com"])
self.present(mailComposeViewController, animated: true)
}
self.deleteMenu()
}
addAnimation()
}
func addAnimation(){
UIView.animate(withDuration: 0.25) { [weak self] in
// self!.mTopView?.top = 0
self!.mineView!.left = 0
self!.mBackView!.backgroundColor = UIColor.colorWithRGB(_r: 0, _g: 0, _b: 0, alpha: 0.5)
} completion: { re in
}
}
func deleteMenu(){
UIView.animate(withDuration: 0.25) { [weak self] in
// self!.mTopView?.bottom = 0
self!.mineView!.left = -SCREEN_Width
self!.mBackView!.backgroundColor = UIColor.colorWithRGB(_r: 0, _g: 0, _b: 0, alpha: 0.01)
} completion: {[weak self] re in
// self!.mTopView?.removeFromSuperview()
// self!.mTopView = nil
self!.mineView?.removeFromSuperview()
self!.mineView = nil
self!.mBackView?.removeFromSuperview()
self!.mBackView = nil
}
}
@objc public func tapsender(sender:UITapGestureRecognizer){
deleteMenu()
}
}
extension CCHomeController: TZImagePickerControllerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate{
func spaceAlbum() {
self.view.addSubview(spaceAlbumPopView)
spaceAlbumPopView.show()
//
spaceAlbumPopView.selectedImageHandler = { [self] data,asset in
gotoPhotoTransformVC(data: data, url: nil,asset: asset)
}
//
spaceAlbumPopView.selectedVideoHandler = { [weak self] url,asset in
if (asset.duration > 60 ) {
if !UserInfo.sharedInstance.isMemberShip {
let vc:MembershipVC = MembershipVC()
let nav = UINavigationController(rootViewController: vc)
nav.modalTransitionStyle = UIModalTransitionStyle.coverVertical
nav.modalPresentationStyle = .fullScreen
self?.present(nav, animated: true)
return
}
}
self?.gotoVideoTransformVC(url: url,asset: asset)
}
}
func gotoPhotoTransformVC(data:Data?,url:URL?,asset:PHAsset?) {
let vc = VRPhotoTransformController()
vc.sourceImageData = data
vc.sourceImageURL = url
vc.imageAsset = asset
self.navigationController?.pushViewController(vc, animated: true)
}
func gotoVideoTransformVC(url:URL?,asset:PHAsset?) {
let vc = VRVideoTransformController()
vc.sourceVideoURL = url
vc.videoOriginalPHAsset = asset
self.navigationController?.pushViewController(vc, animated: true)
}
func photoLibrary() {
//
let status = AVCaptureDevice.authorizationStatus(for: .video)
if status == AVAuthorizationStatus.restricted || status == AVAuthorizationStatus.denied {
let alertC = UIAlertController(title: NSLocalizedString(NSLocalizedString("无法使用相机", comment: ""), comment: ""), message: NSLocalizedString("请前往[设置->隐私安全]中开启访问授权", comment: ""), preferredStyle: .alert)
// let actionCancel = UIAlertAction(title: "Cancel", style: .cancel) { (action:UIAlertAction) in
// }
let actionSet = UIAlertAction(title: NSLocalizedString("设置", comment: ""), style: .cancel) { (action:UIAlertAction) in
let url:URL = URL(string: UIApplication.openSettingsURLString)!
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
// alertC.addAction(actionCancel)
alertC.addAction(actionSet)
self.present(alertC, animated: true, completion: nil)
}else{
//
let picker = UIImagePickerController.init()
picker.delegate = self;
picker.mediaTypes = ["public.image","public.movie"];
picker.sourceType = .photoLibrary;
self.present(picker, animated: true, completion: nil)
}
}
// MARK: - ========== UIImagePickerControllerDelegate ==========
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
print("info = \(info)")
if let mediaType = info[.mediaType] as? String {
switch mediaType {
case "public.image":
//
// let image : UIImage = info[.originalImage] as! UIImage
//url
let imageUrl : URL = info[.imageURL] as! URL
print("选择图片 Selected iamge URL: \(String(describing: imageUrl))")
//PHAsset
// let phAsset : PHAsset = info[UIImagePickerController.InfoKey.phAsset] as! PHAsset
gotoPhotoTransformVC(data: nil, url: imageUrl,asset: info[.phAsset] as? PHAsset)
break
case "public.movie":
let videoURL = info[.mediaURL] as? URL
print("选择视频 Selected video URL: \(String(describing: videoURL))")
gotoVideoTransformVC(url: videoURL,asset: info[.phAsset] as? PHAsset)
// sourceVideoURL = videoURL
// heroAsset1 = AVAsset(url: sourceVideoURL!)
// heroAsset = heroAsset1
// if(!isSpatialVideo(asset: heroAsset!)){
// showTextAlert(title: "", message: "")
// }
// play()
break
default:
print("未知的媒体类型")
break
}
}
picker.dismiss(animated: true, completion: nil)
// if self.photosArray.count >= self.maxImages {
// return SVProgressHUD.showInfo(withStatus: "Add up to \(self.maxImages) photos")
// }
// self.addPicture(image)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
// MARK: - ========== TZImagePickerControllerDelegate ==========
func imagePickerController(_ picker: TZImagePickerController!, didFinishPickingPhotos photos: [UIImage]!, sourceAssets assets: [Any]!, isSelectOriginalPhoto: Bool, infos: [[AnyHashable : Any]]!) {
// if self.photosArray.count >= self.maxImages {
// return SVProgressHUD.showInfo(withStatus: "Add up to \(self.maxImages) photos")
// }
//
// //
// if photos.count > self.maxImages - self.photosArray.count {
// let surplus = self.maxImages - self.photosArray.count
// return SVProgressHUD.showInfo(withStatus: "Up to \(surplus) more photos can be added")
// }
//
// self.addPictures(photos)
// selectedPhotos.append(contentsOf: photos)
// selectedAssets.append(contentsOf: assets)
// listTableView.reloadData()
}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true)
if let error = error {
print(error)
} else {
switch result {
case .cancelled:
print("Mail cancelled")
case .sent:
print("Mail sent")
case .failed:
print("Mail failed")
case .saved:
print("Mail saved")
default:
break
}
}
}
}