Video problem?

16 views
Skip to first unread message

Amine

unread,
Sep 14, 2020, 10:50:59 AM9/14/20
to CodenameOne Discussions
Hi,
I use the code below to play a video from URL. It work on the simulator but does not work on android device (xperia z3+)?
The code :

protected void postTestForm(Form f) {
try {
            Media media;
            media = MediaManager.createMedia("http://178.128.204.162:3000/images/Lcode.maSpotMoutadaribine.mp4", true);
            
            if (media.isNativePlayerMode()) {
                media.setNativePlayerMode(true);
            }
            findCntVideoF().addComponent(media.getVideoComponent());
            media.play();
            Timer t = new Timer();
            TimerTask ta = new TimerTask() {

                public void run() {
                    media.pause();
                }
            };

            t.schedule(ta, 6000);
            
        } catch (Exception ex) {
            Dialog.show("Video Error", ex.getMessage(), "Ok", "Cancel");
        }
}
Kind regards,

IDE: NetBeans 12
Desktop OS
Simulator
Device

Shai Almog

unread,
Sep 14, 2020, 9:48:50 PM9/14/20
to CodenameOne Discussions
Hi,
the IP must be accessible to the device. Android and iOS block HTTP URLs by default (only https is allowed) so try this: https://stackoverflow.com/questions/57121953/usescleartexttraffic-not-permitted/57130188

Amine

unread,
Sep 16, 2020, 9:02:17 AM9/16/20
to CodenameOne Discussions
Hi,
The IP is accessible, and i add int build hint this parameter (see the attached image) but it's still not working.
HTTP.png

Shai Almog

unread,
Sep 17, 2020, 12:21:26 AM9/17/20
to CodenameOne Discussions
Give the findCntVideoF container a BorderLayout and add the media to the center. I'm guessing the video is shrinking to an invisible size because it didn't have time to initialize.
Reply all
Reply to author
Forward
0 new messages