title: How to get time duration from MusicPlayer ( For Midi file ) in iOS?
body: <p>I need to time duration and end event of midi file. I am using below code for play midi file. i tried but didn't found anything. thanks in advance</p>
  
  <pre><code>var s: MusicSequence?
  NewMusicSequence(&amp;s)
  
  let midiFilePath = Bundle.main.path(forResource: "CCL-20180308-A-04", ofType: "mid")
  let midiFileURL = URL(fileURLWithPath: midiFilePath ?? "")
  
  MusicSequenceFileLoad(s!, midiFileURL as CFURL, MusicSequenceFileTypeID(rawValue: 0)!, [])
  
  var p: MusicPlayer?
  NewMusicPlayer(&amp;p)
  
  MusicPlayerSetSequence(p!, s)
  MusicPlayerPreroll(p!)
  MusicPlayerStart(p!)
  
  usleep(3 * 100 * 100)
  var now: MusicTimeStamp = 0
  MusicPlayerGetTime(p!, &amp;now)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rFefD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rFefD.png" alt="enter image description here"></a></p>