Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-25-2011, 05:31 AM   #1 (permalink)
German iPhone dev
 
Join Date: Jun 2009
Location: Düsseldorf
Age: 19
Posts: 28
Gi-lo is on a distinguished road
Send a message via AIM to Gi-lo
Default How to check if MPMediaLibrary did change ?

Hey folks ,

I am building a music application and therefore I cache some data which I grab from the users iPod library first. I need to recreate the cache whenever the iPod library changes so I took a look at MPMediaLibrary.

Actually I found 2 interesting things:

lastModificationDate ->
Due to some googling, I know that this also gets called when the user creates a new playlist or such. Even worse, in my case it shows up the same date all the time.
Code:
NSLog(@"%@", [[MPMediaLibrary defaultMediaLibrary] lastModifiedDate]); // Always the same date
beginGeneratingLibraryChangeNotifications ->
The problem I have with this, is that after the notification is sent the MPMediaQuery is still the same. After around 5 seconds it changes. I dont want to let my users wait 5 seconds ... :/
Code:
[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(_handle_MediaLibraryDidChangeNotification)
                                                 name:MPMediaLibraryDidChangeNotification
                                               object:[MPMediaLibrary defaultMediaLibrary]];
    [[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];
All in all I am pretty frustrated now. Is there no way to check if the iPod library did change?
__________________
Please follow me on Twitter and take a look at my website.
Feel free to add me on AIM (GiloMTTM) to ask me whatever you want
Gi-lo is offline   Reply With Quote
Old 07-25-2011, 05:57 AM   #2 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

Might help, iphone - Load songs from iPod Library right after sync - Stack Overflow

Max.

Quote:
Originally Posted by Gi-lo View Post
Hey folks ,

I am building a music application and therefore I cache some data which I grab from the users iPod library first. I need to recreate the cache whenever the iPod library changes so I took a look at MPMediaLibrary.

Actually I found 2 interesting things:

lastModificationDate ->
Due to some googling, I know that this also gets called when the user creates a new playlist or such. Even worse, in my case it shows up the same date all the time.
Code:
NSLog(@"%@", [[MPMediaLibrary defaultMediaLibrary] lastModifiedDate]); // Always the same date
beginGeneratingLibraryChangeNotifications ->
The problem I have with this, is that after the notification is sent the MPMediaQuery is still the same. After around 5 seconds it changes. I dont want to let my users wait 5 seconds ... :/
Code:
[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(_handle_MediaLibraryDidChangeNotification)
                                                 name:MPMediaLibraryDidChangeNotification
                                               object:[MPMediaLibrary defaultMediaLibrary]];
    [[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];
All in all I am pretty frustrated now. Is there no way to check if the iPod library did change?
iSDK is offline   Reply With Quote
Old 07-25-2011, 08:23 AM   #3 (permalink)
German iPhone dev
 
Join Date: Jun 2009
Location: Düsseldorf
Age: 19
Posts: 28
Gi-lo is on a distinguished road
Send a message via AIM to Gi-lo
Default

Quote:
Originally Posted by iSDK View Post
Thanks for the tip but initializing an instance of MPMediaPicker is always not nil for me. Also I cannot listen for "lastModificationDate" changes, as in my case it is never changing :/
__________________
Please follow me on Twitter and take a look at my website.
Feel free to add me on AIM (GiloMTTM) to ask me whatever you want
Gi-lo is offline   Reply With Quote
Reply

Bookmarks

Tags
cache, ipod, library, mpmedia, music

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 403
16 members and 387 guests
7twenty7, blasterbr, buggen, chiataytuday, Clouds, dre, fiftysixty, HemiMG, jimmyon122, jonathandeknudt, LEARN2MAKE, n00b, nyoe, pungs, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,668
Threads: 94,121
Posts: 402,902
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jonathandeknudt
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:59 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0