I’ve been having a lot of trouble trying to use display.save and display.capture. I’m not sure I fully understand how they work. Are they asynchronous? Nothing in the documentation (that I can find) says they are asynchronous, but in my experiments, it seems like they are.
I’ve rewritten my code a bunch, but the basic idea was this:
-
Get an image from the camera/photo library
-
Pop it onscreen, but resize it to be really small (like a thumbnail)
-
display.save() it
-
go to the next scene
-
display.newImage(my previously saved file from step 3)
And step 5 fails a lot on an iPad 3. It worked fine on iPhone 6 and an Android 4.1 device. I assumed it must be taking longer to save in step 3, so I added a timer.performWithDelay before moving to the next scene, and that worked.
So, if the display.save() is asynchronous, it would really help to have a listener to know when the save is complete. My current workaround is to use the version of media.selectPhoto (and its camera equivalent) that supports saving. This *seems* to not fire the completed listener until it’s saved, but maybe I just got lucky.
Can someone from Corona let me know how that works exactly or update the docs to explain if it’s an asynchronous operation? I’d rather use display.save in this case because of some specific UI reasons that are too complicated to explain. Basically, it doesn’t “feel” right because there’s a long delay when you pick something from the photo library before the screen updates. I’m guessing that’s because it’s taking awhile to save the file, but if it was a separate thing, i could show some kind of “Processing…” message. I can’t do that with it all as one call because it would be showing “Processing” in the background on an iPad while the photo library is on-screen, before they’ve picked anything. It would be weird.
Hope this makes sense.
Thanks,
Dave