Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var speechPlayer = AVAudioPlayer ()
- var currentPlayingItems: [String] = []
- fileprivate func prepareAudioItemsToPlay () {
- var result: [String] = []
- if (introSwitch.isOn) {
- result.append ( "Intro")
- }
- result += audioFileNamesForCurrentLessonType
- currentPlayingItems = result.flatMap ({Bundle.main.path (forResource: $ 0, ofType: "m4a")})
- currentPlayingItemNumber = 0
- fileprivate var audioFileNamesForCurrentLessonType: [String] {
- guard let type = selectedLessonType else {return []}
- switch type {
- case .lesson1:
- if (statusSelection.selectedSegmentIndex == 0) {
- return ["A1", "A2", "A3", "A4", "A5"]
- }
- else if (statusSelection.selectedSegmentIndex == 1) {
- return ["A1", "A6", "A3, "A7", "A8", "A9","A10"]
- }
- ...
- }
- let durations:[String:Int] = ["A1": 1, "A2": 2, "A3": 3, "Intro": 120]
- let fileNames:[String] = ["A1", "A3"]
- let totalDuration = durations.filter{ fileNames.contains($0.key) }.values.reduce(0, +)
Add Comment
Please, Sign In to add comment