Created
March 13, 2014 12:37
-
-
Save coybit/9527639 to your computer and use it in GitHub Desktop.
Downloading audio file and playing it ( A simple replacement for short audio streaming )
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
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| NSURL *mp3URL = [NSURL URLWithString:@"http://zhangmenshiting.baidu.com/data2/music/44799433/4479927746800128.mp3?xcode=dbff90a141d5d136fdc7275fdc3fae126077a44adc974ad8"]; | |
| NSData *data = [NSData dataWithContentsOfURL:mp3URL]; | |
| self.audioPlayer = [[AVAudioPlayer alloc] initWithData:data error:NULL]; | |
| [self.audioPlayer play]; | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found it here: http://stackoverflow.com/a/16975649/946835