1

I'm trying to display image taken from camera plus plugin right below the screen.

For that I'm trying the event named 'photo Captured Event' and realized that the event itself was not triggered. I just put an alert message inside it and confirmed that it is not working. Sample snippet is below, for full workaround, go to this link https://play.nativescript.org/?template=play-js&id=nvIlTl&v=3

CameraPlus.on(nativescript_camera_plus.CameraPlus.photoCapturedEvent, args => {
    fromAsset(args.data).then(result => {
      pic.src = result;
      alert(result);
    });
  });
<GridLayout rows="*,auto" class="home-panel">
        <Cam:CameraPlus row="0" id="camPlus" saveToGallery="true"
            showCaptureIcon="true" showGalleryIcon="true" showToggleIcon="true"
            showFlashIcon="true" debug="true">
        </Cam:CameraPlus>

        <Image row="1" height="150" id="img_taken_id" src="{{ img_taken }}" />
</GridLayout>

First, I need to know why the alert message was not coming? Secondly, I need to display image taken without storing in local?

Important note: I'm trying this for 'android' not IOS

modi
  • 57
  • 8

1 Answers1

2

It's because you are not pointing to the right method. It should be,

let ImageSourceModule = require('tns-core-modules/image-source');
.....
.....
ImageSourceModule.fromAsset(args.data).then(result => {
  pic.src = result;
  alert(result);
});
Manoj
  • 21,753
  • 3
  • 20
  • 41
  • I think you have not checked the scenario. I tried to alert before ImageSourceModule itself. and still it's not working. you can check here https://play.nativescript.org/?template=play-js&id=nvIlTl&v=4 . that's the reason i mentioned photo Captured Event was not triggering. kindly go through the issue because this answer was logically fine but not working. if you answer question without checking i cannot question again by deleting this post. then question goes rust. So, I request you to check the scenario again on any android phone and on playground itself. – modi Jun 03 '19 at 05:03
  • I did check the question and even had it working on your same playground after the above modifications. The image was properly displayed below camera view, replaced the Google image shown initially. – Manoj Jun 03 '19 at 07:02
  • I just tried the above Playground version you have (v4) on device which has the changes I mentioned, I see the alerts as well as image. – Manoj Jun 03 '19 at 07:09
  • can you tell me which phone you used. i don't know but I'm thinking its a compatibility issue of core modules. so this might identify any other problem. also kindly check the updated playground sample and save it. give me the link i'll test on the sample you gave on my phone. may be that will solve the problem. else i'll make a 20second video of the problem and share the link. – modi Jun 03 '19 at 07:16
  • I tried on Moto G5 Plus with Android 8.1, using the same Playground Sample you have in your above comment (https://play.nativescript.org/?template=play-js&id=nvIlTl&v=4). – Manoj Jun 03 '19 at 07:49
  • the problem is with playground it seems. i downloaded the project and run offline and its working in my mobile. – modi Jun 03 '19 at 10:45
  • @Manoj can you tell the answer for 'Secondly, I need to display image taken without storing in local?' . because saveToGallery="false" is not working. even it is false image is saved to gallery. – Vikas Acharya Jun 03 '19 at 12:22