Commit 098f06b8 by SunARcTech2

fix audio progress

parent e7d846fe
No preview for this file type
......@@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>18</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
......
......@@ -17,6 +17,7 @@ class PlayAudioCell: UITableViewCell {
// var audioRecording: AudioRecording?
var delegate: PlayAudioCellDelegate!
@IBOutlet var btnPlay: UIButton!
@IBOutlet var audioSlider: UISlider!
var audioRecording: AudioRecording? {
......@@ -35,6 +36,7 @@ class PlayAudioCell: UITableViewCell {
@IBAction func playAudio() {
if audioRecording?.isPlaying == true {
Audio.pause()
delegate.audioPlayingAt(index: 10000)
} else {
playAudioFile()
delegate.audioPlayingAt(index: audioRecording!.audioIndex)
......@@ -49,7 +51,13 @@ class PlayAudioCell: UITableViewCell {
}, failure: { (errorMesaage) in
self.viewController()?.view.showToast(errorMesaage, position: .bottom, popTime: 2.0, dismissOnTap: false)
}) { (progress, duration) in
print("progress = \(progress) duration = \(duration)")
self.audioSlider.maximumValue = duration
self.audioSlider.value = progress
if Int(duration) == Int(progress) {
self.delegate.audioPlayingAt(index: 10000)
}
}
}
......
......@@ -108,14 +108,16 @@ extension CompletedServicesViewController: UITableViewDelegate, UITableViewDataS
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId == "booking" {
// if selectedService.serviceType == .BOOKING {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.orderStatus = .COMPLETE
// appointmentdetails.serviceStatus = .completed
appointmentdetails.incrementId = selectedService.incrementId
appointmentdetails.orderId = selectedService.orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq" {
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -130,8 +132,8 @@ extension CompletedServicesViewController: UITableViewDelegate, UITableViewDataS
enquiryDetailsViewController.orderId = selectedService.orderId!
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "forms"{
// } else if selectedService.serviceType == .FORM{
if let form = Form.VC(with: selectedService.incrementId!, orderId: selectedService.orderId!, categoryType: selectedService.categoryType){
self.navigationController?.pushViewController(form, animated: true)
}
......
......@@ -22,10 +22,9 @@ class EditResultViewController: BaseViewController {
var recommendedProducts = [RecommendProduct]()
var isAllowAccessMicrophone = true
var orderId = "0"
var editResult = EditResult()
var audioPlayedAtIndex = 10000
override func viewDidLoad() {
super.viewDidLoad()
......@@ -67,6 +66,10 @@ extension EditResultViewController {
let alertActionNo = UIAlertAction(title: "No", style: .default) { (action) in }
let alertActionYes = UIAlertAction(title: "Yes", style: .default) { (action) in
print(self.imagesForResult.count)
print(self.audioRecordings.count)
self.editResult.images = self.imagesForResult
self.editResult.audios = self.audioRecordings
self.editResult.products = self.recommendedProducts
......@@ -181,6 +184,15 @@ extension EditResultViewController: UITableViewDelegate, UITableViewDataSource {
audioRecordings[indexPath.row].audioIndex = indexPath.row
playAudioCell.audioRecording = audioRecordings[indexPath.row]
playAudioCell.delegate = self
playAudioCell.audioSlider.value = 0
playAudioCell.btnPlay.tag = indexPath.row
if audioPlayedAtIndex == indexPath.row {
playAudioCell.btnPlay.setBackgroundImage(UIImage(named: "pause"), for: .normal)
} else {
playAudioCell.btnPlay.setBackgroundImage(UIImage(named: "play"), for: .normal)
}
return playAudioCell
default:
return UITableViewCell()
......@@ -283,13 +295,16 @@ extension EditResultViewController: PlayAudioCellDelegate {
func audioPlayingAt(index: Int) {
for (arrayIndex, audioRecording) in audioRecordings.enumerated() {
if arrayIndex == index {
audioRecording.isPlaying = true
} else {
audioRecording.isPlaying = false
}
}
audioPlayedAtIndex = index
// for (arrayIndex, audioRecording) in audioRecordings.enumerated() {
// if arrayIndex == index {
// audioRecording.isPlaying = true
// } else {
// audioRecording.isPlaying = false
// }
// }
tblresult.reloadData()
}
......
......@@ -108,14 +108,16 @@ extension InvalidServicesViewController: UITableViewDelegate, UITableViewDataSou
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId == "booking"{
// if selectedService.serviceType == .BOOKING {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.orderStatus = .CLOSED
// appointmentdetails.serviceStatus = .completed
appointmentdetails.incrementId = selectedService.incrementId
appointmentdetails.orderId = selectedService.orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq" {
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -130,8 +132,8 @@ extension InvalidServicesViewController: UITableViewDelegate, UITableViewDataSou
enquiryDetailsViewController.orderId = selectedService.orderId!
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "forms"{
// } else if selectedService.serviceType == .FORM{
if let form = Form.VC(with: selectedService.incrementId!, orderId: selectedService.orderId!, categoryType: selectedService.categoryType){
self.navigationController?.pushViewController(form, animated: true)
}
......
......@@ -107,8 +107,8 @@ extension OnGoingServicesViewController: UITableViewDelegate, UITableViewDataSou
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId! == "booking" {
// if selectedService.serviceType == .BOOKING {
if selectedService.status == .SERVICE_ONGOING {
let videoCallVC = Utils.viewController(storyboardName: "Appointment", ofType: VideoCallingViewController.self)
videoCallVC.orderId = selectedService.orderId!
......@@ -120,7 +120,8 @@ extension OnGoingServicesViewController: UITableViewDelegate, UITableViewDataSou
// appointmentdetails.incrementId = selectedService.incrementId
// appointmentdetails.orderId = selectedService.orderId
// self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq" {
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -135,8 +136,8 @@ extension OnGoingServicesViewController: UITableViewDelegate, UITableViewDataSou
enquiryDetailsViewController.orderId = selectedService.orderId!
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "forms"{
// } else if selectedService.serviceType == .FORM{
if let form = Form.VC(with: selectedService.incrementId!, orderId: selectedService.orderId!, categoryType: selectedService.categoryType) {
self.navigationController?.pushViewController(form, animated: true)
......
......@@ -107,15 +107,16 @@ extension ProcessingViewController: UITableViewDelegate, UITableViewDataSource {
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId == "booking"{
// if selectedService.serviceType == .BOOKING {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.orderStatus = .PROCESSING
// appointmentdetails.serviceStatus = .tbc
appointmentdetails.incrementId = selectedService.incrementId
appointmentdetails.orderId = selectedService.orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq"{
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -130,8 +131,8 @@ extension ProcessingViewController: UITableViewDelegate, UITableViewDataSource {
enquiryDetailsViewController.orderId = selectedService.orderId!
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "forms"{
// } else if selectedService.serviceType == .FORM{
if let form = Form.VC(with: selectedService.incrementId!, orderId: selectedService.orderId!, categoryType: selectedService.categoryType) {
self.navigationController?.pushViewController(form, animated: true)
......
......@@ -425,15 +425,16 @@ extension MasterReplyCell: UITableViewDelegate, UITableViewDataSource, ResultAud
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let audioCell = tableView.dequeueReusableCell(withIdentifier: "ResultAudioCell", for: indexPath) as! ResultAudioCell
audioCell.audioPath = arrayOfAudios[indexPath.row]
audioCell.cellIndex = indexPath.row
audioCell.delegate = self
audioCell.btnPlay.tag = 0
audioCell.btnPlay.tag = indexPath.row
audioCell.audioSlider.value = 0
if indexPath.row == playingAudioAtIndex {
audioCell.btnPlay.setBackgroundImage(UIImage(named: "pause"), for: .normal)
audioCell.btnPlay.tag = 8080
audioCell.isPlayingAudio = true
} else {
audioCell.btnPlay.setBackgroundImage(UIImage(named: "play"), for: .normal)
audioCell.isPlayingAudio = false
}
return audioCell
}
......@@ -456,16 +457,16 @@ protocol ResultAudioCellDelegate {
class ResultAudioCell: UITableViewCell {
@IBOutlet var btnPlay: UIButton!
@IBOutlet var audioSlider: UISlider!
var audioPath: String?
var delegate: ResultAudioCellDelegate?
var cellIndex = 0
var isPlayingAudio = false
@IBAction func play() {
print("tag = \(btnPlay.tag)")
if btnPlay.tag == 8080 {
if isPlayingAudio == true {
Audio.pause()
btnPlay.tag = 0
delegate?.playingAudioAtIndex(index: 1000)
......@@ -473,14 +474,15 @@ class ResultAudioCell: UITableViewCell {
}
if let audioPath = audioPath {
delegate?.playingAudioAtIndex(index: btnPlay.tag)
Audio.playAudio(audioPath: audioPath, success: {
}, failure: { (errorMesaage) in
self.viewController()?.view.showToast(errorMesaage, position: .bottom, popTime: 2.0, dismissOnTap: false)
}) { (progress, duration) in
print("progress = \(progress) duration = \(duration)")
self.audioSlider.maximumValue = duration
self.audioSlider.value = progress
}
} else {
......
......@@ -145,7 +145,8 @@ extension HomePageViewController: UITableViewDelegate, UITableViewDataSource {
let order = dashboard.orders[indexPath.row-1]
if order.products.first?.serviceType == .BOOKING {
if order.products.first?.typeId == "booking" {
// if order.products.first?.serviceType == .BOOKING {
if order.status == .SERVICE_ONGOING {
let videoCallVC = Utils.viewController(storyboardName: "Appointment", ofType: VideoCallingViewController.self)
......@@ -159,7 +160,8 @@ extension HomePageViewController: UITableViewDelegate, UITableViewDataSource {
self.navigationController?.pushViewController(appointmentdetails, animated: true)
}
} else if order.products.first?.serviceType == .FAQ {
} else if order.products.first?.typeId == "faq" {
// } else if order.products.first?.serviceType == .FAQ {
if order.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -178,7 +180,8 @@ extension HomePageViewController: UITableViewDelegate, UITableViewDataSource {
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if order.products.first?.serviceType == .FORM{
} else if order.products.first?.typeId == "forms" {
// } else if order.products.first?.serviceType == .FORM{
if order.status == .COMPLETE {
......
......@@ -32,6 +32,7 @@ class OnlineEnquiryViewController: BaseViewController {
var customerId: String?
var chatCountId = ""
var recordingPermissionGranted = false
var playAudioAtIndex: Int64 = 10000
override func viewDidLoad() {
super.viewDidLoad()
......@@ -277,11 +278,27 @@ extension OnlineEnquiryViewController: UITableViewDelegate, UITableViewDataSourc
if chat.name == "Seller" {
let masterAudioCell = tableView.dequeueReusableCell(withIdentifier: "masterAudio") as! OnlineEnquiryMasterAudioCell
masterAudioCell.audioPath = chat.msg
masterAudioCell.delegate = self
masterAudioCell.btnPlay.tag = indexPath.row
masterAudioCell.progressSlider.value = 0.0
if playAudioAtIndex == indexPath.row {
masterAudioCell.btnPlay.setBackgroundImage(UIImage(named: "pause"), for: .normal)
} else {
masterAudioCell.btnPlay.setBackgroundImage(UIImage(named: "play"), for: .normal)
}
return masterAudioCell
} else {
let customerAudioCell = tableView.dequeueReusableCell(withIdentifier: "customerAudio") as! OnlineEnquiryCustomerAudioCell
customerAudioCell.audioPath = chat.msg
customerAudioCell.customerProfileImage = customerProfileImage
customerAudioCell.delegate = self
customerAudioCell.btnPlay.tag = indexPath.row
customerAudioCell.progressSlider.value = 0.0
if playAudioAtIndex == indexPath.row {
customerAudioCell.btnPlay.setBackgroundImage(UIImage(named: "pause"), for: .normal)
} else {
customerAudioCell.btnPlay.setBackgroundImage(UIImage(named: "play"), for: .normal)
}
return customerAudioCell
}
}
......@@ -290,6 +307,12 @@ extension OnlineEnquiryViewController: UITableViewDelegate, UITableViewDataSourc
}
}
extension OnlineEnquiryViewController: OnlineEnquiryMasterAudioCellDelegate, OnlineEnquiryCustomerAudioCellDelegate {
func playPausTapped(atIndex: Int64) {
playAudioAtIndex = atIndex
self.tblChat.reloadData()
}
}
extension OnlineEnquiryViewController: UITextViewDelegate {
......@@ -352,16 +375,24 @@ class OnlineEnquiryCustomerCell: UITableViewCell {
}
}
protocol OnlineEnquiryMasterAudioCellDelegate {
func playPausTapped(atIndex: Int64)
}
class OnlineEnquiryMasterAudioCell: UITableViewCell {
@IBOutlet var btnPlay: UIButton!
var audioPath: String?
@IBOutlet var imgMaster: UIImageView!
@IBOutlet var progressSlider: UISlider!
var audioPath: String?
var delegate: OnlineEnquiryMasterAudioCellDelegate?
var isAudioPlaying = false
@IBAction func play() {
delegate?.playPausTapped(atIndex: Int64(btnPlay!.tag))
if let audioPath = audioPath {
Audio.playAudio(audioPath: audioPath, success: {
......@@ -389,16 +420,24 @@ class OnlineEnquiryMasterAudioCell: UITableViewCell {
}
protocol OnlineEnquiryCustomerAudioCellDelegate {
func playPausTapped(atIndex: Int64)
}
class OnlineEnquiryCustomerAudioCell: UITableViewCell {
@IBOutlet var btnPlay: UIButton!
var audioPath: String?
var customerProfileImage: String?
@IBOutlet var imgCostomer: UIImageView!
@IBOutlet var progressSlider: UISlider!
var audioPath: String?
var customerProfileImage: String?
var delegate: OnlineEnquiryCustomerAudioCellDelegate?
@IBAction func play() {
delegate?.playPausTapped(atIndex: Int64(btnPlay!.tag))
if let audioPath = audioPath {
Audio.playAudio(audioPath: audioPath, success: {
......
......@@ -123,8 +123,8 @@ extension MyAllServiceOrderViewController: UITableViewDelegate, UITableViewDataS
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId == "booking" {
// if selectedService.serviceType == .BOOKING {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
switch service.services[indexPath.row].status {
case .CANCELED:
......@@ -151,7 +151,8 @@ extension MyAllServiceOrderViewController: UITableViewDelegate, UITableViewDataS
appointmentdetails.incrementId = selectedService.incrementId
appointmentdetails.orderId = selectedService.orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq" {
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -170,8 +171,8 @@ extension MyAllServiceOrderViewController: UITableViewDelegate, UITableViewDataS
enquiryDetailsViewController.customerName = service.services[indexPath.row].customerName
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "form" {
// } else if selectedService.serviceType == .FORM{
if selectedService.status == .COMPLETE {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
......
......@@ -101,14 +101,15 @@ extension MyCompletedOrdersViewController: UITableViewDelegate, UITableViewDataS
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId == "booking" {
// if selectedService.serviceType == .BOOKING {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.serviceStatus = .completed
appointmentdetails.incrementId = selectedService.incrementId
appointmentdetails.orderId = selectedService.orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq" {
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -126,7 +127,8 @@ extension MyCompletedOrdersViewController: UITableViewDelegate, UITableViewDataS
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "forms" {
// } else if selectedService.serviceType == .FORM{
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.incrementId = selectedService.incrementId
......
......@@ -102,7 +102,8 @@ extension MyOngoingServiceOrderViewController: UITableViewDelegate, UITableViewD
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId == "booking" {
// if selectedService.serviceType == .BOOKING {
if selectedService.status == .SERVICE_ONGOING {
let videoCallVC = Utils.viewController(storyboardName: "Appointment", ofType: VideoCallingViewController.self)
......@@ -115,7 +116,8 @@ extension MyOngoingServiceOrderViewController: UITableViewDelegate, UITableViewD
// appointmentdetails.incrementId = selectedService.incrementId
// appointmentdetails.orderId = selectedService.orderId
// self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq" {
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -131,7 +133,8 @@ extension MyOngoingServiceOrderViewController: UITableViewDelegate, UITableViewD
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "forms" {
// } else if selectedService.serviceType == .FORM{
if let form = Form.VC(with: selectedService.incrementId!, orderId: selectedService.orderId!, categoryType: selectedService.categoryType){
self.navigationController?.pushViewController(form, animated: true)
......
......@@ -102,13 +102,15 @@ extension MyUploadResultViewController: UITableViewDelegate, UITableViewDataSour
let selectedService = service.services[indexPath.row]
if selectedService.serviceType == .BOOKING {
if selectedService.typeId == "booking" {
// if selectedService.serviceType == .BOOKING {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.serviceStatus = .tbc
appointmentdetails.incrementId = selectedService.incrementId
appointmentdetails.orderId = selectedService.orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if selectedService.serviceType == .FAQ {
} else if selectedService.typeId == "faq" {
// } else if selectedService.serviceType == .FAQ {
if selectedService.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
......@@ -124,7 +126,8 @@ extension MyUploadResultViewController: UITableViewDelegate, UITableViewDataSour
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else if selectedService.serviceType == .FORM{
} else if selectedService.typeId == "forms" {
// } else if selectedService.serviceType == .FORM{
if let form = Form.VC(with: selectedService.incrementId!, orderId: selectedService.orderId!, categoryType: selectedService.categoryType) {
self.navigationController?.pushViewController(form, animated: true)
......
......@@ -23,6 +23,9 @@ class EditResult {
func updateResult(for orderId: String, success: @escaping () -> Void, failure: @escaping (_ errorMesage: String) -> Void) {
print(self.images.count)
print(self.audios.count)
self.uploadAudios(index: 0) {
self.uploadImages(index: 0) {
......@@ -30,6 +33,13 @@ class EditResult {
self.uploadedProducts = self.uploadedProducts + "," + product.entityId!
}
if self.uploadedImages.count > 0 {
self.uploadedImages.removeFirst()
}
if self.uploadedAudios.count > 0 {
self.uploadedAudios.removeFirst()
}
let parameters: [String: Any] = ["storeId": UserDefaults.standard.value(forKey: "storeId") as! String,
"orderId": orderId,
"reply_text": self.message,
......@@ -38,7 +48,6 @@ class EditResult {
"products": self.uploadedProducts
]
SVProgressHUD.show()
let headers = [
......@@ -184,7 +193,6 @@ class EditResult {
}
}
}
}
}
......
......@@ -54,67 +54,70 @@ class Product {
var qty: Int = 0
var serviceType = ServiceType.UNKNOWN
var categoryType = CategoryType.Unknown
var typeId: String?
func initWithJSON(json: Any) {
if let response = json as? [String: Any] {
self.productId = response["productId"] as? String
self.name = response["name"] as? String
self.qty = response["qty"] as! Int
self.typeId = response["typeId"] as? String
if let categoryType_ = response["category_type"] as? String {
self.categoryType = CategoryType(rawValue: categoryType_)!
switch self.categoryType {
case .OnlineFAQ:
self.serviceType = .FAQ
case .FortuneOfTheYear:
fallthrough
case .VideoFortuneTelling:
fallthrough
case .OnlineFaceReading:
self.serviceType = .BOOKING
case .IndividualNamingServiceNamed:
fallthrough
case .IndividualNamingServiceReNamedChangeName:
fallthrough
case .CompanyNamingServiceNamed:
fallthrough
case .CompanyNamingServiceReNamedChangeName:
fallthrough
case .FloorPlanFengShuiGeomancy:
fallthrough
case .FloorPlanFengShuiCorporateFengShui:
fallthrough
case .OnsiteServiceGeomancy:
fallthrough
case .OnsiteServiceCorporateFengShui:
fallthrough
case .Groundbreaking:
fallthrough
case .Registration:
fallthrough
case .MovingHouse:
fallthrough
case .MovingCompany:
fallthrough
case .StartOpeningBusiness:
fallthrough
case .Marriage:
fallthrough
case .GODSetting:
fallthrough
case .BedSetting:
self.serviceType = .FORM
case .MoreServices:
self.serviceType = .MORE
case .Unknown:
self.serviceType = .UNKNOWN
}
}
// if let categoryType_ = response["category_type"] as? String {
// self.categoryType = CategoryType(rawValue: categoryType_)!
//
// switch self.categoryType {
// case .OnlineFAQ:
// self.serviceType = .FAQ
//
// case .FortuneOfTheYear:
// fallthrough
// case .VideoFortuneTelling:
// fallthrough
// case .OnlineFaceReading:
// self.serviceType = .BOOKING
//
//
// case .IndividualNamingServiceNamed:
// fallthrough
// case .IndividualNamingServiceReNamedChangeName:
// fallthrough
// case .CompanyNamingServiceNamed:
// fallthrough
// case .CompanyNamingServiceReNamedChangeName:
// fallthrough
// case .FloorPlanFengShuiGeomancy:
// fallthrough
// case .FloorPlanFengShuiCorporateFengShui:
// fallthrough
// case .OnsiteServiceGeomancy:
// fallthrough
// case .OnsiteServiceCorporateFengShui:
// fallthrough
// case .Groundbreaking:
// fallthrough
// case .Registration:
// fallthrough
// case .MovingHouse:
// fallthrough
// case .MovingCompany:
// fallthrough
// case .StartOpeningBusiness:
// fallthrough
// case .Marriage:
// fallthrough
// case .GODSetting:
// fallthrough
// case .BedSetting:
// self.serviceType = .FORM
//
// case .MoreServices:
// self.serviceType = .MORE
// case .Unknown:
// self.serviceType = .UNKNOWN
// }
// }
}
}
......
......@@ -40,6 +40,8 @@ class Service {
var serviceType = ServiceType.UNKNOWN
var categoryType = CategoryType.Unknown
var typeId: String?
var currentPage = 1
var maxPageNo = 0
var isBooking = false
......@@ -48,8 +50,6 @@ class Service {
func initWithJSON(json: [String: Any]) {
print(json)
if let status = json["status"] as? String {
self.status = MyServiceStatus(rawValue: status)!
}
......@@ -62,60 +62,61 @@ class Service {
self.productName = productInfo["name"] as? String
self.productId = productInfo["productId"] as? String
self.customerId = productInfo["customer_id"] as? String
self.typeId = productInfo["typeId"] as? String
if let categoryType_ = productInfo["category_type"] as? String {
self.categoryType = CategoryType(rawValue: categoryType_)!
switch self.categoryType {
case .OnlineFAQ:
self.serviceType = .FAQ
case .FortuneOfTheYear:
fallthrough
case .VideoFortuneTelling:
fallthrough
case .OnlineFaceReading:
self.serviceType = .BOOKING
case .IndividualNamingServiceNamed:
fallthrough
case .IndividualNamingServiceReNamedChangeName:
fallthrough
case .CompanyNamingServiceNamed:
fallthrough
case .CompanyNamingServiceReNamedChangeName:
fallthrough
case .FloorPlanFengShuiGeomancy:
fallthrough
case .FloorPlanFengShuiCorporateFengShui:
fallthrough
case .OnsiteServiceGeomancy:
fallthrough
case .OnsiteServiceCorporateFengShui:
fallthrough
case .Groundbreaking:
fallthrough
case .Registration:
fallthrough
case .MovingHouse:
fallthrough
case .MovingCompany:
fallthrough
case .StartOpeningBusiness:
fallthrough
case .Marriage:
fallthrough
case .GODSetting:
fallthrough
case .BedSetting:
self.serviceType = .FORM
case .MoreServices:
self.serviceType = .MORE
case .Unknown:
self.serviceType = .UNKNOWN
}
}
// if let categoryType_ = productInfo["category_type"] as? String {
// self.categoryType = CategoryType(rawValue: categoryType_)!
//
// switch self.categoryType {
// case .OnlineFAQ:
// self.serviceType = .FAQ
//
// case .FortuneOfTheYear:
// fallthrough
// case .VideoFortuneTelling:
// fallthrough
// case .OnlineFaceReading:
// self.serviceType = .BOOKING
//
// case .IndividualNamingServiceNamed:
// fallthrough
// case .IndividualNamingServiceReNamedChangeName:
// fallthrough
// case .CompanyNamingServiceNamed:
// fallthrough
// case .CompanyNamingServiceReNamedChangeName:
// fallthrough
// case .FloorPlanFengShuiGeomancy:
// fallthrough
// case .FloorPlanFengShuiCorporateFengShui:
// fallthrough
// case .OnsiteServiceGeomancy:
// fallthrough
// case .OnsiteServiceCorporateFengShui:
// fallthrough
// case .Groundbreaking:
// fallthrough
// case .Registration:
// fallthrough
// case .MovingHouse:
// fallthrough
// case .MovingCompany:
// fallthrough
// case .StartOpeningBusiness:
// fallthrough
// case .Marriage:
// fallthrough
// case .GODSetting:
// fallthrough
// case .BedSetting:
// self.serviceType = .FORM
//
// case .MoreServices:
// self.serviceType = .MORE
// case .Unknown:
// self.serviceType = .UNKNOWN
// }
// }
}
}
......
......@@ -16,6 +16,7 @@ class Audio {
var audioPlayer: AVPlayer?
var audioPlayerForLocalFile: AVAudioPlayer?
var currentRecordingPath: String?
var timer: Timer?
static let shared = Audio()
var Timestamp: String {
......@@ -64,7 +65,6 @@ class Audio {
// class func playAudio(audioPath: String, success:() -> Void, failure: (_ message: String) -> Void) {
if audioPath.first == "/" { // local file path
let audioURL = URL(fileURLWithPath: audioPath)
do {
......@@ -74,6 +74,21 @@ class Audio {
try Audio.shared.audioPlayerForLocalFile = AVAudioPlayer(contentsOf: audioURL)
Audio.shared.audioPlayerForLocalFile!.prepareToPlay()
Audio.shared.audioPlayerForLocalFile!.play()
Audio.shared.timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { (timer) in
let currentTime = Float(Audio.shared.audioPlayerForLocalFile!.currentTime)
let duration = Float(Audio.shared.audioPlayerForLocalFile!.duration)
progress(Float(currentTime), Float(duration.isNaN == true ? 0.0 : duration))
if Audio.shared.audioPlayerForLocalFile?.isPlaying == true {
progress(Float(currentTime), Float(duration.isNaN == true ? 0.0 : duration))
} else {
progress(1000.0, 1000.0)
Audio.shared.timer?.invalidate()
}
}
success()
} catch {
failure(error.localizedDescription)
......@@ -112,6 +127,7 @@ class Audio {
if Audio.shared.audioPlayer != nil {
Audio.shared.audioPlayer!.pause()
Audio.shared.audioPlayerForLocalFile?.pause()
Audio.shared.timer?.invalidate()
}
}
......
......@@ -1626,7 +1626,7 @@
<constraint firstAttribute="height" constant="45" id="XbZ-vL-zoL"/>
<constraint firstAttribute="width" constant="45" id="Z29-nc-MV1"/>
</constraints>
<state key="normal" image="play"/>
<state key="normal" backgroundImage="play"/>
<connections>
<action selector="play" destination="vtw-sw-ByE" eventType="touchUpInside" id="1bv-0J-FCh"/>
</connections>
......@@ -1683,7 +1683,7 @@
<constraint firstAttribute="width" constant="45" id="79P-yY-OHu"/>
<constraint firstAttribute="height" constant="45" id="kNY-xT-qzo"/>
</constraints>
<state key="normal" image="play"/>
<state key="normal" backgroundImage="play"/>
<connections>
<action selector="play" destination="LQQ-dP-WjW" eventType="touchUpInside" id="REZ-mg-ckA"/>
</connections>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment