i able play sound in swift nssound:
var path ="/path/to/file.mp3" mysound = nssound(contentsoffile: path, byreference: false) mysound!.play() // works! if (mysound!playing) { mysound!.pause() //works, sort of } mysound!playing // still true.
how check see if it's paused?
the docs show pause() supposed return false if playback paused, doesn't seem case, or doing wrong
i'd able this:
var path ="/path/to/file.mp3" mysound = nssound(contentsoffile: path, byreference: false) if (mysound!playing) { var state = mysound!.pause() if(state == false) { mysound!.resume() //never gets executed - why? } } else { mysound!.play() }
i use figuring out! thanks!
the sound paused if called pause() , returns true. documentation doesn't qualify, paused nssound might technically still return true playing. make sense if playing
considered "not stopped".
since know if you've called pause(), can store bool ispaused
, , use that.
in second example, you're not calling play(), playing
return false.
Comments
Post a Comment