I did lots of R&D on BPM but did not get any answer that resolve my issue. I am trying to get BPM value from MPmediaItem class of ios for my iphone application.I have to categorize my app users on the basis of beats per minute of their library songs. So my first task to find out BPM of songs. How can I do that? I got some answers like: 1.using MPMediaItemPropertyBeatsPerMinute property and 2. Use #"beatsPerMinutes" instaed of MPMediaItemPropertyBeatsPerMinute property of MPMediaItem class and also some more answer, but didnot get any success. It has always same result for all songs (return null for all songs). Do you have any sample code or logic to get this.
Thanks in advance.
Try this:
int BPM = [[mediaItem valueForProperty:MPMediaItemPropertyBeatsPerMinute]intValue];
Related
I’m new in Swift and I need to extract all data related to workouts from HealthKit and use it in JavaScript (I'm making a React Native app), so I made a query but its predicate only pass one workout e.g .cycling, what I need is to get all workouts, even if the user has it or not, let's say: get all workouts recorded (even if they are differents) by the user in a list.
I need: Running {...} Cycling {....} Pilates {...}
but I'm getting : Cycling 1 Cycling 2 Cycling 3
In brief, I need a predicate to do this. my code:
You should be passing a nil predicate to the HKSampleQuery to retrieve all workouts regardless of their type.
I'm currently trying my hardest but can't get anywhere. I can get the current track using iTunes.currentTrack but the .artworks() SBElementArray doesn't really get me anywhere since I don't know what to do with it. There is also #objc public protocol iTunesArtwork: iTunesItem { but I don't know how to get there either.
Any help would be appreciated.
Thanks!
You can get the raw data out of one of the items and make an NSImage out of it. This is Objective-C, but it should directly translate over.
[[NSImage alloc] initWithData:[[[currentTrack artworks] firstObject] rawData]];
My object from app, syncronize with server every 5 min. And user can check his items in web. I generate for him the following link:
"http://mydomain/items/\(self.appDelegate.UUID.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!)/\(items.objectID.URIRepresentation().absoluteString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!)"
UUID - this is device or icloud key.
So the link looks like:
http://mydomain/items/15FDA6B3-C51A-4057-8F98-0143981CC5C8/x-coredata://60DD8665-3136-4CF0-9FD3-FF9164FC7327/Items/p1
But can i cut x-coredata://60DD8665-3136-4CF0-9FD3-FF9164FC7327 to this: /Items/p1. Does it will be unique ?
Or any other ideas how to make look better item id.
Yes maybe better create own id, but i found another solution:
let id = Item.objectID.uriRepresentation().absoluteString.components(separatedBy: "/p")[1]
And result will be integer value.
Apple is encouraging us to use the new PhotosFramework to interact with the camera roll in iOS8. But says nothing about AssetsLibraryFramework not working on iOS8.
So I'm using my pre-existing AssetsLibraryFramework code to do get the list of video ALAssets from the user's camera roll and display it. This works...still.
But when I try to create an album (group) using this AssetsLibraryFramework method:
- (void)addAssetsGroupAlbumWithName:(NSString *)name
resultBlock:(ALAssetsLibraryGroupResultBlock)resultBlock
failureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock
Where resultBlock looks like this:
typedef void (^ALAssetsLibraryGroupResultBlock)(ALAssetsGroup *group));
The resultBlock is called with a nil group. The docs say that the group will be nil for a name collision, but there's no other album with the specified name. Definitely not a name collision.
I'm trying to determine if this is an error on my part, or evidence that ALAssetsLibrary cannot be trusted on iOS8 and I need to upgrade to PhotosFramework.
Are there other things that could cause the group to be nil? Is this method just not supported on iOS8?
Thanks in advance for any help.
I have the following data model:
And I'd like to have a property on the playlist object that points to its list of songs. Right now I have something like:
self.songs = [self.playlistMemberships valueForKey:#"song"];
But I'm noticing that this is very slow and core data seems to be firing off faults for each individual song. Any thoughts on how to make a single call to pull all the song info? Thanks!
PlaylistMembership just seems to get in the way -- can you relate Playlist to Song directly and cut out the PlaylistMembership? I think that'd let Core Data fetch all the songs at once rather than fetching all the memberships and then having to go back to get each song.
If you can't or prefer not to get rid of the membership entity, use setRelationshipKeyPathsForPrefetching: to specify that song should be fetched along with the membership.