Copying music files of iphone library in my app - iphone

I want to copy the music files of iphone ipod library using MPMediaPicker. Actually using MPMediaPicker I am able to get the path of ipod music library but when I convert music file at url in NSData, the result is null. I doubt that is it possible to get the music file from ipod library. I am not sure as there is no exception or warning while I am trying to convert url item in NSData using [NSData datawithContentOfUrl:ipod-library-path].
If someone has any idea about this or any alternative to copy music files.

Your are getting Asset URLof music files.So it need to be converted into NSData to write into iphone library.
Refer Get video NSData from ALAsset url iOS link.
Now write data into iphone library.

Related

.m4a file is not playing while uploading to server

In my app i am uploading .m4a music file from iphone library (storing in core data) which is downloaded from itunes, problem is the uploaded file is not playing (even in browser), some times the uploaded file is of 4MB size, in server it is showing 20KB. If i upload a .mp3 file it is perfectly uploading and perfectly playing. please help me.My code follows like this.
[request addData:[managedobject valueForKey:#"songData"] withFileName:[managedobject valueForKey:#"song_name"] andContentType:nil forKey:#"file"];
[request setPostValue:[managedobject valueForKey:#"song_extension"] forKey:#"extension"];
Try manually uploading the file to your server to verify that it will play at all... because of Apples Fairplay (http://en.wikipedia.org/wiki/FairPlay) DRM, I have had trouble playing songs bought off the store as well. However, if this is not the case, then recheck your upload code because something is wrong.

Is it possible to access raw iphone audio output?

Is it possible access raw PCM data from the iphone audio output?
I know I can embed an MP3 and use AudioUnit. But if the user is playing music in the background from their itunes library, is it possible to access that audio data?
This is for an app that shows visual effects, which react to the music.
From what I can tell, it isn't possible, but that's just from lack of finding any information at all, rather than actual confirmation that it can't be done.
If it isn't possible to access the audio stream from the ipod, is it possible to access raw audio output from the Media Player inside an app, or is pretty much not permitted to access raw audio data from the itunes library at all?
EDIT: I found this question: iOS - Access output audio from background program, which say I can't access the audio from a background app. But is it possible to get the audio data from the itunes library if I play it inside the app?
I am busy coding something similar and as far as I know an AUGraph is needed, the hardware pulling from the recorder. You will have to get the URL of the MPMediaItem from the track the user selected with Apple's MPMediaPickerViewController. Then use the URL with Core-Audio. Core-Audio is a beast.
If your app is playing raw audio PCM samples, then your app has access to those samples. An app does not have access to the audio samples that another app (including the Music player) is playing via any public API.
An app can use AVAssetReader and Writer to convert mp3 files from the iTunes Library into raw audio (WAV) files.

upload mp3 audio file from ipod library to remote server

Is it possible to upload mp3 audio file from ipod library to remote server?
I want to upload a song directly from ipod to reomote server using PHP script, I can access songs library using MPMediaPicket but unable to form a NSData request through it?
No you can't.
audios from iPod Library are protected and you can only access through limit apis that provided by apple.
Only AV Foundation Can access ipod library,So,You can use AVAssetReader + AVAssetWriter to export the music from ipod library to Your document ,then u can r/w it and do anything.
U can reference this QAs:
1.
Extract iPod Library raw PCM samples and play with sound effects.
2.
http://www.subfurther.com/blog/2010/07/19/from-iphone-media-library-to-pcm-samples-in-dozens-of-confounding-potentially-lossy-steps/
3.
http://www.subfurther.com/blog/2010/12/13/from-ipod-library-to-pcm-samples-in-far-fewer-steps-than-were-previously-necessary/

How To put Audio song in NSdata In iphone

I want to hold ipod Library song in NSData to send on Webservice.
how i can get that song in NSdata
You can't do that unfortunately (at least without doing something 'illegal'). Apple has iPod Library access API: http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/iPodLibraryAccess_Guide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008765
However these only allow you to pick songs, read meta data, tell ipod to play songs... not much else

Can audio files be saved like photos and movies in iphone using objective C?

If our iphone application uses the inbuilt camera to click any picture, for saving the image into iPhone's photo library, we use UIImageWriteToSavedPhotosAlbum method. Likewise, to store any video recording into the iPhone, we use UISaveVideoAtPathToSavedPhotosAlbum
Is there any method to save any audio file into iPhone's Sounds library akin to both the methods mentioned above?
There is no way to import audio into the iPod application from the phone. iTunes (on the computer) is currently the only way. You do have a few options to save the file though
1) Create a movie on your own with just the audio
2) save it to disk locally (in the documents directory) and provide a way to get it off the phone (such as CocoaHTTPServer)
3) Email it.
4) Upload to a server