Last active
December 29, 2015 10:29
-
-
Save jdelStrother/7657209 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @interface MyAudioPlayer() { | |
| AVAudioPlayer* currentPlayer; | |
| } | |
| @end | |
| @implementation MyAudioPlayer | |
| +(instance_type)sharedPlayer { | |
| static MyAudioPlayer* sharedPlayer; | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| sharedPlayer = [[MyAudioPlayer alloc] init]; | |
| }); | |
| return sharedPlayer; | |
| } | |
| -(void)playURL:(NSURL*)url { | |
| [currentPlayer stop]; | |
| currentPlayer = [[AVAudioPlayer alloc] initWithURL: url]; | |
| [currentPlayer prepareToPlay]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment