Detecting music video from iPhone/Pad music library - iphone

Im using MPMediaQuery to search the library on a user's iPhone/Pad. Im able to return audio tracks but im unable to return any of the videos which are on the device. Apparently its not possible according to this article but i fail to understand why this would be. If that is true, is there another way to retrive this information?
This is how im retrieving tracks
MPMediaQuery *queryTracksByArtist = [MPMediaQuery artistsQuery];
MPMediaPropertyPredicate *pred = [MPMediaPropertyPredicate predicateWithValue:#"The Album Title" forProperty:MPMediaItemPropertyAlbumArtist comparisonType:MPMediaPredicateComparisonContains];
[queryTracksByArtist addFilterPredicate:pred];
NSArray *itemsFromGenericQuery = [queryTracksByArtist items];

No, As of now, you cannot access video with ipod library access. check this link.

Related

iPhone audio equalizer

I am playing video from the web with AVPlayerLayer :
AVAsset *newAsset = [[AVURLAsset alloc]initWithURL:url options:nil];
AVPlayerItem *newPlayerItem = [[AVPlayerItem alloc]initWithAsset:newAsset];
audioPlayer = [[AVPlayer alloc]initWithPlayerItem:newPlayerItem];
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:audioPlayer];
And i want to be able to add Audio Equalizer to the video. Something like :
Pop, Flat, Balled, Blues, Classical, Dance, Metal
I search for and documentation for this in Google and in apple developer program resources and didn't find nothing.
And i also noticed that some apps have this function, but it's for iOS 6.1 only.
Any help with this issue? Did apple have something build-in or it's a non-apple source?
This Stack Overflow question has answers offering several different solutions: How to make a simple EQ AudioUnit (bass, mid, treble) with iOS?

commonMetadata array empty for some songs from iPod library

I'm using a MPMediaPickerControllerto enable the user to pick songs from the device's iPod library. Then I put this songs into an array (in this case playerQueue) and use an AVPlayer instance to play one song after the other:
- (void)setQueueWithItemCollection:(MPMediaItemCollection *)theCollection {
for (MPMediaItem *theMediaItem in theCollection.items) {
NSURL *mediaURL = [theMediaItem valueForProperty:MPMediaItemPropertyAssetURL];
AVPlayerItem *thePlayerItem = [AVPlayerItem playerItemWithURL:mediaURL];
// Don't add protected tracks to queue as they cannot be played
if (!thePlayerItem.asset.hasProtectedContent && thePlayerItem.asset.isPlayable) [self.playerQueue addObject:thePlayerItem];
// Further implementation
}
}
Now I get the song title using this code snippet (with AVPlayer *musicPlayer):
AVPlayerItem *currentItem = self.musicPlayer.currentItem;
AVAsset *asset = currentItem.asset;
// Further implementation
NSLog(#"DEBUG: Meta data: %#", asset.commonMetadata);
NSArray *titles = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
Most times this works without any problem. But there are are also songs for which asset.commonMetadata returns an empty array. However the Music app on my iPhone is able to display the song title (and album artwork etc.) just like iTunes (on the Mac).
The song file is an Apple MPEG 4 Audio file purchased from the iTunes Store.
Why is asset.commonMetadata returning an empty array even though there are meta data available?
I was having this same problem with downloaded m4b audio files. Turns out that AVURLAsset requires the URL string to end in '.m4b' (other audio extensions would work, I suspect). You can't use the URL as is if it is something like http://source.com/download.php?id=12345. Otherwise, the asset.commonMetaData just returns an empty array. I don't know if this is a problem with iTunes assetURLs, but it would be easy to check.
The only solution that worked for me:
Use AudioToolbox.framework to retrieve metadata from such files, i.e. use AudioFileGetProperty function.
It seems like a real bug in AVFoundation…

Video searching

I'm developing app for IPhones where users clicks button, gets the list of all videos from his IPhone and uploads chosen video to server.
I know how to upload video to server, but I don't know how to implement video searching.
How can I get pathes to all videos (in users IPhone) in Array?
(Currently my IPhone is unavailable for use, so I'd like to know also how to test video search in IPhone Simulator?)
Kind Regards
You need to use the UIImagePickerController component, configuring it to show only videos when browsing the library.
You can do that by setting the mediaTypes property of the picker in this way:
myImagePickerController.mediaTypes =
[[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
Then if you want to test it in the simulator, you need to save some videos on it and you can use the UISaveVideoAtPathToSavedPhotosAlbum function to achieve that. Check out this great answer for more detailed instructions.
This link shows how to access only videos from the photoroll since all videos of the device should be stored there, you should be able to access them from there: Picking video from PhotoLibrary with UIImagePickerController in OS 3.1

How to get the number of music files our device having

iam developing one application.In that i need to get the how many music files are there in my device.Iam using the MPMediaPickerController for selecting the music files.But i want to get the number of files that device having with open and select the files from the picker.So please tell me how to get that number.
To get all the songs use the following
MPMediaQuery *allSongsQuery= [MPMediaQuery songsQuery];
NSArray *songs = [allSongsQuery collections];
If you want open and select, you will have to do some more work

How to Play Videos Files from an iPod Video Library?

How can I play video files in my application from an iPod video library? Is there any other possibility to search and play video files stored anywhere in an iPhone?
You can't The iPod Library access is audio only at this time. There is currently no way to access any video outside of your application sandbox (in other words, you can only search through and play video your app has downloaded itself).
If you need access to the video library you should file a bug with Apple describing why you need it.
You can play video files store in device, there are 3 places you can search :
Camera Roll : video recorded
iPod Library
File Sharing
After searching on internet I found this sample of Apple describe how to get and play those videos.
Here is AVPlayerDemo
Hope this will help you. Good luck :)
MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInteger:MPMediaTypeMovie] forProperty:MPMediaItemPropertyMediaType];
MPMediaQuery *query = [[MPMediaQuery alloc] init];
[query addFilterPredicate:predicate];
NSArray *items = [query items];
NSURL url = [[NSURL alloc]init];
for (MPMediaItem item in items)
{
//get the Title of video
NSString* title = [item valueForProperty:MPMediaItemPropertyTitle];
NSLog(#"title %#",title);
//get the path of Video
url = [item valueForProperty:MPMediaItemPropertyAssetURL];
NSLog(#"url %#",url);
}