How can I save a snapshot image (taken with userMedia) locally and load it later on?

1 favourites
From the Asset Store
Template for a generic save / load system, fully documented in comments and video
  • By design, Sprites all share the same textures. To show different images you'll need to load different images in to different animation frames.

  • Thank you Ashley, it does seems to be the cause of the problem. I am setting different frame number for each image and then invoking the load image from URL and doesn't work either. Is there another way to load images into different frames?

  • It should work. I can only assume your events are wrong.

  • Ashley sorry to bother again, I´ve made many tests, and think I found the root cause. When using the code you provided (adapted to camera) and the binaryData, Ajax and LocalStorage stuff, I save and then load an image later on without any problem, but when saving more than one in different localstorage keys (w_photo_0, w_photo_1), it just retrieves the last picture binary saved. I´ve made many tests, even calling them one by one and loading in different frames, debugged it and logged it on console, and always same result. Do you have an idea what is going on in here? Thank you very much for your help.

  • It should work. Again, I can only assume your events are wrong. Providing a project is the quickest way to solve problems.

  • Ashley, I´ve tried to asolate the problem. Here´s a sample capx showing what I need to accomplish, but as Localstorage get binary is asynchronous, I can´t find the way to iterate localstorage and show saved pictures one by one. I also tried to iterate through LocalStorage Keys, but the problem remains the same. Hope you see my point in capx, and really hope this can be performed with C3. Thank you for all your great support.

    Project Link

  • Change your code like this:

  • Thanks very much for your help, that´s a great idea. However, I couldn´t make it work fine either. Did it work for you?

  • Yes, it works:

    You need to wait several seconds before making each shot to allow time to save them.

    Also, if you need to save images between sessions, you might want to save the value of PhotoIdCounter too.

  • gberenst - your events are indeed wrong. You try to load all the pictures in to the same Binary Data object at once so they will all overwrite each other. Try loading them one at a time.

  • Yes Ashley, I was wrong, after testing a while I knew that was happening but couldn´t find the way to load them gradually and automatically without loosing some values from variables I needed during the iteration (and loopindex*X seconds action to give some time not to overlap binary data inside the iteration didn´t work out).

    However, the solution brought by dop2000 worked perfectly! (My latest version still didn´t work out after dop2000 post because of an uncommented old event) Thank you guys very much for your help!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You are welcome, but my "solution" was just a quick and dirty fix for retrieving multiple keys from local storage in a loop. I don't know if the rest of the code is correct.

  • dop2000, I took your version and made some minor changes to tidy up things, like sprites positions in list. Here´s final version, thank you!


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)