修复bug
This commit is contained in:
1
Podfile
1
Podfile
@@ -25,6 +25,7 @@ pod 'Qiniu'
|
||||
|
||||
pod 'TZImagePickerController'
|
||||
pod 'LookinServer', :configurations => ['Debug']
|
||||
pod 'StreamingKit'
|
||||
|
||||
# Pods for yinmeng-ios
|
||||
|
||||
|
@@ -1009,6 +1009,7 @@
|
||||
INFOPLIST_FILE = "yinmeng-ios/Info.plist";
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "音萌";
|
||||
INFOPLIST_KEY_NSCameraUsageDescription = "“音萌”需要您的同意,才可以访问进行拍照,才可以在聊天中分享图片给他人查看,或上传图片以更新头像";
|
||||
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "“音萌”需要您的同意,才能进行定位服务,推荐附近好友";
|
||||
INFOPLIST_KEY_NSMicrophoneUsageDescription = "\"音萌\"需要您的同意,才可以进行语音聊天";
|
||||
INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "“音萌”需要您的同意,才可以存储相片到相册";
|
||||
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "“音萌”需要您的同意,才可以访问相册并选择图片,然后在聊天中分享图片给他人查看,或上传图片以更新头像";
|
||||
@@ -1052,6 +1053,7 @@
|
||||
INFOPLIST_FILE = "yinmeng-ios/Info.plist";
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "音萌";
|
||||
INFOPLIST_KEY_NSCameraUsageDescription = "“音萌”需要您的同意,才可以访问进行拍照,才可以在聊天中分享图片给他人查看,或上传图片以更新头像";
|
||||
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "“音萌”需要您的同意,才能进行定位服务,推荐附近好友";
|
||||
INFOPLIST_KEY_NSMicrophoneUsageDescription = "\"音萌\"需要您的同意,才可以进行语音聊天";
|
||||
INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "“音萌”需要您的同意,才可以存储相片到相册";
|
||||
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "“音萌”需要您的同意,才可以访问相册并选择图片,然后在聊天中分享图片给他人查看,或上传图片以更新头像";
|
||||
|
@@ -92,6 +92,7 @@ class YMNetworkHelper: NSObject {
|
||||
if codeNum == 401 && UrlSss.contains("auth-center/sso/logout") == false {
|
||||
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "SessionTickValid"), object: nil)
|
||||
sessionNetMana.cancelAllRequests()
|
||||
keyWindow.rootViewController = BaseNavigationViewController(rootViewController:AuthLaunchVC())
|
||||
}
|
||||
var messageIn = response1.error.debugDescription
|
||||
if ResultMo.keys.contains("message") { messageIn = ResultMo["message"] as? String ?? "" }
|
||||
|
@@ -6,3 +6,5 @@
|
||||
#import <SVGAPlayer/SVGA.h>
|
||||
#import "RecordVoiceManager.h"
|
||||
#import <Qiniu/QiniuSDK.h>
|
||||
#import <StreamingKit/STKAudioPlayer.h>
|
||||
|
||||
|
@@ -2,8 +2,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>“音萌”需要您的同意,才能进行定位服务,推荐附近好友</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
@@ -14,5 +12,9 @@
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>audio</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@@ -17,7 +17,7 @@ class HomeVoiceUserInfoView: UIView {
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setUILayout()
|
||||
|
||||
self.dissView.addTarget(self, action: #selector(dissViewAction), for: .touchUpInside)
|
||||
}
|
||||
func setUILayout(){
|
||||
backgroundColor = UIColor(white: 0, alpha: 0.8)
|
||||
@@ -210,10 +210,11 @@ class HomeVoiceUserInfoView: UIView {
|
||||
}
|
||||
@objc func dissViewAction(){
|
||||
self.removeFromSuperview()
|
||||
PlayVoiceManager.shared.stopPlayVoice()
|
||||
}
|
||||
var dissView:UIButton = {
|
||||
let _dissView = UIButton()
|
||||
_dissView.addTarget(self, action: #selector(dissViewAction), for: .touchUpInside)
|
||||
|
||||
return _dissView
|
||||
}()
|
||||
var backgroundView:UIView = {
|
||||
|
@@ -7,11 +7,13 @@
|
||||
|
||||
import UIKit
|
||||
import Alamofire
|
||||
class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
||||
|
||||
static let shared = PlayVoiceManager()
|
||||
var player:AVAudioPlayer?
|
||||
|
||||
|
||||
class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
||||
|
||||
static let shared = PlayVoiceManager()
|
||||
var player:AVAudioPlayer?
|
||||
|
||||
var isPlay = false
|
||||
func stopPlayVoice(){
|
||||
guard let player = player else{return}
|
||||
@@ -26,7 +28,7 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
||||
guard let _url = URL.init(string: url) else {
|
||||
return
|
||||
}
|
||||
self.player = try? AVAudioPlayer.init(contentsOf: _url)
|
||||
self.player = try? AVAudioPlayer(contentsOf: _url)
|
||||
self.player?.volume = 1
|
||||
self.player?.numberOfLoops = -1
|
||||
self.player?.delegate = self
|
||||
@@ -35,75 +37,68 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate {
|
||||
isPlay = true
|
||||
}
|
||||
func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) {
|
||||
print(flag)
|
||||
|
||||
}
|
||||
func audioPlayerDecodeErrorDidOccur(_ player: AVAudioPlayer, error: Error?) {
|
||||
print(error)
|
||||
|
||||
}
|
||||
func downloadVoice(url:String){
|
||||
func downloadVoice(url:String){
|
||||
|
||||
let list = url.components(separatedBy: "/")
|
||||
var name = "voiceList"
|
||||
if list.isEmpty == false,let getName = list.last{
|
||||
name = getName
|
||||
}
|
||||
let path = NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask,true)[0] as String
|
||||
|
||||
|
||||
let allPath = path + "/kUserVoice/" + name
|
||||
try? FileManager.default.removeItem(atPath: allPath)
|
||||
if FileManager.default.fileExists(atPath: allPath){
|
||||
beginPlayVoice(url: allPath)
|
||||
}else{
|
||||
// try? FileManager.default.createDirectory(atPath: allPath, withIntermediateDirectories: true, attributes: nil)
|
||||
try? FileManager.default.createDirectory(atPath: allPath, withIntermediateDirectories: true, attributes: nil)
|
||||
downloadDataWithUrl(url: url, path: allPath)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func downloadDataWithUrl(url:String,path:String){
|
||||
|
||||
//请求
|
||||
let request = URLRequest(url: URL(string: url)!)
|
||||
|
||||
let session = URLSession.shared
|
||||
//下载任务
|
||||
let downloadTask = session.downloadTask(with: request,
|
||||
completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
|
||||
//请求
|
||||
let request = URLRequest(url: URL(string: url)!)
|
||||
let session = URLSession.shared
|
||||
//下载任务
|
||||
let downloadTask = session.downloadTask(with: request,
|
||||
completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
|
||||
-> Void in
|
||||
let locationPath = location!.path
|
||||
let getUlr = URL.init(string: path)
|
||||
let locationUrl = URL.init(string: locationPath)
|
||||
|
||||
|
||||
let data = try? NSData.dataWithContentsOfMappedFile(locationPath)
|
||||
if let _data = data as? Data{
|
||||
do{
|
||||
FileManager.default.createFile(atPath: path, contents: _data)
|
||||
self.beginPlayVoice(url:path)
|
||||
let locationPath = location!.path
|
||||
if FileManager.default.fileExists(atPath: path){
|
||||
try? FileManager.default.removeItem(atPath: path)
|
||||
}
|
||||
catch{
|
||||
|
||||
do {
|
||||
// 文件移动至document
|
||||
try FileManager.default.copyItem(atPath: locationPath, toPath: path)
|
||||
// main
|
||||
DispatchQueue.main.async {
|
||||
self.beginPlayVoice(url:path)
|
||||
}
|
||||
} catch let error {
|
||||
debugPrint(error)
|
||||
HUDTool.show(with: "\(error.localizedDescription)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// let data = NSData.init(contentsOfFile: locationPath)
|
||||
// if let _data = data {
|
||||
// let isHave = _data.write(toFile: path, atomically: true)
|
||||
// print(isHave)
|
||||
// self.beginPlayVoice(url:path)
|
||||
// }
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
//使用resume方法启动任务
|
||||
downloadTask.resume()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user