RTSP Video link

167 views
Skip to first unread message

EnprohSoft Tech

unread,
Sep 15, 2013, 8:29:43 AM9/15/13
to codenameone...@googlegroups.com
 How do i play an rtsp video link in a browser or media player? tried the following but did not work: 

Media media = MediaManager.createMedia(link, true); if (media.isNativePlayerMode()) { media.setNativePlayerMode(true); } media.play();

Brian Karoney

unread,
Sep 15, 2013, 9:59:21 AM9/15/13
to codenameone...@googlegroups.com
Hi there,

It seems you are not getting the video component and assigning it to a container, what error message are you getting?  Try this code:

//VideoForm is an instance of the form I use in this example
//video is the container that diplays the video on the form referenced by findVideo(VideoForm);
String link="http://mediaurl.com/"; url for the video

        try {
            media = MediaManager.createMedia(link, true);
            findVideo(VideoForm).addComponent(BorderLayout.CENTER, media.getVideoComponent());
       
       if (media.isNativePlayerMode()) { media.setNativePlayerMode(true); } media.play();
       
        } catch (Exception ex) {
            Dialog.show("Video Error", ex.getMessage(), "Ok", null);
        }



The above code works for my rtsp url.

EnprohSoft Tech

unread,
Sep 15, 2013, 1:18:30 PM9/15/13
to codenameone...@googlegroups.com
@Brian Thanks for your response, but here is a trace of the error message:

java.lang.UnsupportedOperationException: Unsupported protocol "rtsp"
at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:234)
at javafx.scene.media.Media.<init>(Media.java:364)
at com.codename1.impl.javase.JavaSEPort$CodenameOneMediaPlayer.<init>(JavaSEPort.java:4614)
at com.codename1.impl.javase.JavaSEPort$38.run(JavaSEPort.java:3631)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
java.io.IOException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: Unsupported protocol "rtsp"
at com.codename1.impl.javase.JavaSEPort.createMedia(JavaSEPort.java:3651)
at com.codename1.ui.Display.createMedia(Display.java:2547)
at com.codename1.media.MediaManager.createMedia(MediaManager.java:80)
at com.codename1.media.MediaManager.createMedia(MediaManager.java:50)
at userclasses.StateMachine.onHome_Button1Action(StateMachine.java:203)
at generated.StateMachineBase.handleComponentAction(StateMachineBase.java:541)
at generated.StateMachineBase.processCommand(StateMachineBase.java:250)
at com.codename1.ui.util.UIBuilder.processCommandImpl(UIBuilder.java:1597)
at com.codename1.ui.util.UIBuilder.access$100(UIBuilder.java:83)
at com.codename1.ui.util.UIBuilder$FormListener.actionPerformed(UIBuilder.java:2686)
at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:383)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:326)
at com.codename1.ui.Form.actionCommandImplNoRecurseComponent(Form.java:1218)
at com.codename1.ui.Button.fireActionEvent(Button.java:372)
at com.codename1.ui.Button.released(Button.java:407)
at com.codename1.ui.Button.pointerReleased(Button.java:495)
at com.codename1.ui.Form.pointerReleased(Form.java:2183)
at com.codename1.ui.Form.pointerReleased(Form.java:2129)
at com.codename1.ui.Component.pointerReleased(Component.java:2286)
at com.codename1.ui.Display.handleEvent(Display.java:1766)
at com.codename1.ui.Display.edtLoopImpl(Display.java:970)
at com.codename1.ui.Display.mainEDTLoop(Display.java:899)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:119)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Caused by: java.lang.RuntimeException: java.lang.UnsupportedOperationException: Unsupported protocol "rtsp"
at com.codename1.impl.javase.JavaSEPort$CodenameOneMediaPlayer.<init>(JavaSEPort.java:4622)
at com.codename1.impl.javase.JavaSEPort$38.run(JavaSEPort.java:3631)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.UnsupportedOperationException: Unsupported protocol "rtsp"
at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:234)
at javafx.scene.media.Media.<init>(Media.java:364)
at com.codename1.impl.javase.JavaSEPort$CodenameOneMediaPlayer.<init>(JavaSEPort.java:4614)
... 9 more
java.lang.UnsupportedOperationException: Unsupported protocol "rtsp"
at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:234)
at javafx.scene.media.Media.<init>(Media.java:364)
at com.codename1.impl.javase.JavaSEPort$CodenameOneMediaPlayer.<init>(JavaSEPort.java:4614)
at com.codename1.impl.javase.JavaSEPort$38.run(JavaSEPort.java:3631)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)

 And here is my code:

    protected void beforeVideos(Form f) {
        Media media;

        
        try {
            media = MediaManager.createMedia(link, true);
            findVideo(f).addComponent(BorderLayout.CENTER, media.getVideoComponent());

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/qNwyPdbfIfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/4b9b29fe-5726-438f-8256-0ecda7041d21%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Regards
Rapheal O. Imara
Chief Solutions Architect
EnprohSoft Technology
+234 802 316 8805
Man's Mind is his only obstacle.
www.enprohsms.com


Brian Karoney

unread,
Sep 15, 2013, 1:47:10 PM9/15/13
to codenameone...@googlegroups.com
@Enproh that error is because the simulator browser does not support the rtsp protocol. The app should work just fine when you deploy it to an android device.


On Sunday, September 15, 2013 3:29:43 PM UTC+3, EnprohSoft Tech wrote:

EnprohSoft Tech

unread,
Sep 16, 2013, 7:27:07 AM9/16/13
to codenameone...@googlegroups.com
I am interested in the RIM build and so when i tested it on Blackberry, i had this error: "APN is not specified". Please advise, thanks a lot


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/qNwyPdbfIfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

For more options, visit https://groups.google.com/groups/opt_out.

Shai Almog

unread,
Sep 16, 2013, 12:58:35 PM9/16/13
to codenameone...@googlegroups.com

EnprohSoft Tech

unread,
Sep 17, 2013, 12:03:15 AM9/17/13
to codenameone...@googlegroups.com
Thanks a lot, but I am actually trying to play a YouTube video. I tested it on the blackberry simulators and it works just fine. But when i tested it on a RIM device, i get the following error: "An internal application error occurred: java.lang.ClassCastException". Find below my code:

 
    @Override
    protected void beforeBrowser(Form f) {
         WebBrowser browser = new WebBrowser();
         Container subCenterContainer = new Container();
         
         subCenterContainer.setLayout(new BorderLayout());
         subCenterContainer.addComponent(BorderLayout.CENTER, browser);
         f.addComponent(BorderLayout.CENTER, subCenterContainer);
         browser.setURL("http://www.youtube.com/embed/M7lc1UVf-VE");
    
    }

Please advise. 


On Mon, Sep 16, 2013 at 5:58 PM, Shai Almog <shai....@gmail.com> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/qNwyPdbfIfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

For more options, visit https://groups.google.com/groups/opt_out.

Shai Almog

unread,
Sep 17, 2013, 1:04:13 AM9/17/13
to codenameone...@googlegroups.com
I don't think the class cast exception is from here, I suggest looking at the alt-lglg device log and checking out the stack trace for the exception.
Also notice that RIM doesn't use the native webkit browser by default since that browser is so flaky, you can enable it by defining within the build arguments:
rim.ignor_legacy=true
rim.nativeBrowser=true

Notice that this could reduce your app stability.

EnprohSoft Tech

unread,
Sep 17, 2013, 2:18:25 AM9/17/13
to codenameone...@googlegroups.com

I have done this, the exception doesn't show any longer, but it also doesn't play at all.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/qNwyPdbfIfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

EnprohSoft Tech

unread,
Sep 17, 2013, 5:47:54 AM9/17/13
to codenameone...@googlegroups.com
How do i add a command to a button to execute a URL programmatically? Or how do i launch the browser on RIM programmatically  to execute the YOUTUBE url. I entered the url directly on the RIM browser and it played well.

Chen Fishbein

unread,
Sep 17, 2013, 6:26:53 AM9/17/13
to codenameone...@googlegroups.com
Hi,
Try this: Display.getInstance().execute(<url>);


EnprohSoft Tech

unread,
Sep 17, 2013, 6:30:58 AM9/17/13
to codenameone...@googlegroups.com
thanks i will try it out


On Tue, Sep 17, 2013 at 11:26 AM, Chen Fishbein <cf2...@gmail.com> wrote:
Hi,
Try this: Display.getInstance().execute(<url>);


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/qNwyPdbfIfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

For more options, visit https://groups.google.com/groups/opt_out.

EnprohSoft Tech

unread,
Sep 17, 2013, 9:22:13 AM9/17/13
to codenameone...@googlegroups.com
Thanks a lot, it worked


On Tue, Sep 17, 2013 at 11:26 AM, Chen Fishbein <cf2...@gmail.com> wrote:
Hi,
Try this: Display.getInstance().execute(<url>);


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/qNwyPdbfIfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages