在应用程序中存储短audio文件/stream媒体

我打算做一个应用程序,利用Parse.com后端用户authentication/post/追随者/等我希望用户能够上传一个样本音乐文件parsing(或一个备用的解决scheme),然后能够stream或让其他人能够stream动它。 我被告知可以使用PFFile存储文件,但是如何将它stream式传输呢?

这也会违反苹果的规定,因为最终它将允许用户通过应用程序购买这些音乐文件,或者我将不得不使用iTunes账户/某种文件?

我在这里先向您的帮助表示感谢

就上传来parsing:

PFObject *testObject = [PFObject objectWithClassName:@"TestObject"]; //get the audio in NSData format NSString *filePath = [[NSBundle mainBundle] pathForResource:@"02 Interstellar Overdrive" ofType:@"m4a"]; NSData *audioData = [NSData dataWithContentsOfFile:filePath]; //create PFFile to store audio data PFFile *audioFile = [PFFile fileWithName:@"02 Interstellar Overdrive.m4a" data:audioData]; testObject[@"audioFile"] = audioFile; //save [testObject saveInBackground]; 

在从Parse服务器stream式传输的方面,使用允许stream式传输的AVPlayer。 如果您想在播放之前首先下载整首歌曲,您可以使用AVAudioPlayer:

 PFQuery *query = [PFQuery queryWithClassName:@"TestObject"]; [query whereKeyExists:@"audioFile"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { PFObject *testObject = [objects lastObject]; PFFile *audioFile = testObject[@"audioFile"]; NSString *filePath = [audioFile url]; //play audiofile streaming self.avPlayer = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:filePath]]; self.avPlayer.volume = 1.0f; [self.avPlayer play]; } else { NSLog(@"error = %@", [error userInfo]); } }]; 

不能说苹果是否会让你在你的应用中销售音乐。