Features and Bugs
After showing the app around, I got a lot of input how to improve the concep
- Instead of the slider show a waveform to make identifying the section easier
- Set marker for start and end to replay the loop
- Persist already set markers
- Mark tracks which already have markers
- Start and stop playing via Siri
- When selecting a track which is not on your device at the moment, the app crashes
- the layout is not suitable for landscape orientation
- Track time and slider jitter
Fixing Bugs
The concept of iTunes is to show all your music which you’ve ever bought. That means that the assetURL of a media item can be nil. To work around that issue you can intercept the seque transition with
shouldPerformSegue()
if self.shouldPerformSegue(withIdentifier: "showPlayer", sender: self) { self.performSegue(withIdentifier: "showPlayer", sender: self) }
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { if identifier == "showPlayer"{ let indexPath = tableView.indexPathForSelectedRow! if mediaItems?[indexPath.row].assetURL == nil{ let alert = UIAlertController(title: "Song is not on your device!", message: "Please download it via music player app", preferredStyle: .alert) let cancelAction = UIAlertAction(title: "OK", style: .default, handler: nil) alert.addAction(cancelAction) self.present(alert, animated: true, completion: { print("completion block") }) return false } return true } return true }