Skip to content

Instantly share code, notes, and snippets.

@coybit
Created March 13, 2014 12:37
Show Gist options
  • Select an option

  • Save coybit/9527639 to your computer and use it in GitHub Desktop.

Select an option

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 )
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];
});
@coybit
Copy link
Author

coybit commented Mar 13, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment