Guest User

Untitled

a guest
Nov 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. var speechPlayer = AVAudioPlayer ()
  2. var currentPlayingItems: [String] = []
  3.  
  4. fileprivate func prepareAudioItemsToPlay () {
  5. var result: [String] = []
  6.  
  7. if (introSwitch.isOn) {
  8. result.append ( "Intro")
  9. }
  10.  
  11. result += audioFileNamesForCurrentLessonType
  12.  
  13. currentPlayingItems = result.flatMap ({Bundle.main.path (forResource: $ 0, ofType: "m4a")})
  14. currentPlayingItemNumber = 0
  15.  
  16. fileprivate var audioFileNamesForCurrentLessonType: [String] {
  17. guard let type = selectedLessonType else {return []}
  18. switch type {
  19.  
  20. case .lesson1:
  21. if (statusSelection.selectedSegmentIndex == 0) {
  22. return ["A1", "A2", "A3", "A4", "A5"]
  23. }
  24. else if (statusSelection.selectedSegmentIndex == 1) {
  25. return ["A1", "A6", "A3, "A7", "A8", "A9","A10"]
  26. }
  27. ...
  28. }
  29.  
  30. let durations:[String:Int] = ["A1": 1, "A2": 2, "A3": 3, "Intro": 120]
  31. let fileNames:[String] = ["A1", "A3"]
  32. let totalDuration = durations.filter{ fileNames.contains($0.key) }.values.reduce(0, +)
Add Comment
Please, Sign In to add comment