problem with capture video

16 views
Skip to first unread message

Fuad Nassar

unread,
Oct 4, 2018, 12:06:37 PM10/4/18
to CodenameOne Discussions
hi, 
I try to use this code to capture and show video 


Capture.PNG



and then when running it under ( 4.4.4 Android Version ) I get something like this message "the camera was stopped" (in finally  process failed)
but when I use (6.1 Version) I get this message "Allow appname to access photo, media, and files on your device?"(in finally process done) 
my question: why this difference of result and what I can do to solve and dispose of these messages.

Thomas

unread,
Oct 4, 2018, 3:34:29 PM10/4/18
to CodenameOne Discussions
Please, post the code as text because it is impossible to read it from your screenshot...
Message has been deleted

Fuad Nassar

unread,
Oct 4, 2018, 6:19:32 PM10/4/18
to CodenameOne Discussions
 final Form hi = new Form("Hi World");
    hi.setLayout(new BorderLayout());

    Button bCapture = new Button("Capture Media");
    bCapture.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ect) {
            try {
                final MediaPlayer mpPlayer = new MediaPlayer();
                String value = Capture.captureVideo();
                System.out.println("Captured Video " + value);
                if (value != null) {
                    System.out.println("Playing Video");
                    InputStream is = FileSystemStorage.getInstance().openInputStream(value);
                    String strMime = "video/mp4";
                    System.out.println("Input Stream" + is.available());
                    mpPlayer.setName("bla");
                    mpPlayer.setDataSource(is, strMime, new Runnable() {
                        public void run() {
                            System.out.println("reset the clip for playback");
                        }
                    });
                    hi.addComponent(BorderLayout.CENTER, mpPlayer);
                    hi.revalidate();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    );
    hi.addComponent(BorderLayout.NORTH, bCapture);

    hi.show();

Shai Almog

unread,
Oct 5, 2018, 12:14:22 AM10/5/18
to CodenameOne Discussions
Android 6+ changed the permission behavior to prompt for permission when you try to use device capabilities such as camera etc. That explains that behavior.
I'm not sure why you would get that a camera was stopped but it might be a crash of the camera native activity, there isn't much we can do about those things.
Reply all
Reply to author
Forward
0 new messages