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