alexbw / novocaine

Painless high-performance audio on iOS and Mac OS X
http://alexbw.github.com/novocaine/
MIT License
2.23k stars 274 forks source link

Audio Reader NSURL Refresh #56

Closed BGerard closed 11 years ago

BGerard commented 11 years ago

Hey guys, I have on Audio Player instance and I need to change its input URL once it has finished playing a song.

My code works by getting an instance of the iPodMusicPlayer from the MPMusicPlayerController class within the MediaPlayer.framework. It then gets the now playing items NSURL and runs it through TSLibraryImport (https://github.com/tapsquare/TSLibraryImport) to allow me to use it within my app. TSLibraryImport then provides me with another NSURL which I then feed to Novocains AudioReader Class. The reader is working fine when I run my "getSongData" method once but I need to run this method every time the NSURL changes. I have code to do this,but when I run the method the audio reader is playing however I do not hear any sound. I'm thinking this could have something to do with some data that it caches from when the reader was first initialised, but i'm not so sure. Basically, I just need to be able to call the "getSongData" method multiple times, asif I was making a new player with a different loop each time.

Heres my code ( I won't include the header as i'm sure you can work out whats global etc):

https://ghostbin.com/paste/jj6f8

I would appreciate some guidance as i'm sure its a relatively simple problem to some.

Note: I know the reader is playing and that I am getting a new NSURL each time due to logging.

BGerard commented 11 years ago

I have fixed the problem. First I modified my "getSongData" method to pause the audiocontroller and then modified the audiocontroller (Novocaine) class and made "freeBuffers" and instance method so I could then call [self freeBuffers]; from within my "getSongData" method.