13 Replies Latest reply: May 12, 2010 3:41 AM by 759167 RSS

    display video using JMF

    408764
      Hello,
      i want to get some video from my database and display it using the java media framework. My code (copied from an example) looks something like this: conn is initialized as a Connection object before.

      private void playVideo () throws SQLException, Exception {
      conn.setAutoCommit(true);

      Statement stmt = conn.createStatement();
      OracleResultSet rs =
      (OracleResultSet)stmt.executeQuery(
      "SELECT video FROM videodemo WHERE video_id = 1");
      if (rs.next()) {
      MediaLocator locator = new MediaLocator
      ("im://thin/hostname:port:sid/user:passwort/" +
      "SELECT t.video.getcontent(), t.video.getmimetype()" +
      " FROM videodemo t WHERE t.video_id = 1");
      DataSource source = Manager.createDataSource(locator);
      Player player = Manager.createPlayer(source);
      player.start();
      }
      else
      throw new SQLException( "row not found" );
      rs.close();
      stmt.close();
      }

      videodemo contains 3 columns, video_id(number), video_name(varchar) and video(ORDVideo).
      When executing my program I gain the following error message:

      javax.media.NoDataSourceException: Cannot find a DataSource for: im://thin/mithrandir:1521:TestDB/scott:tiger/SELECT video.getcontent(), video.getmimetype() FROM videodemo WHERE video_id = 1
           at javax.media.Manager.createDataSource(Manager.java:1037)
           at intermediatest.InterMediaTest.playVideo(InterMediaTest.java:273)
           at intermediatest.InterMediaTest.main(InterMediaTest.java:48)


      He can't create the MediaLocator.
      The situation on my computer is this: I installed JMF and downloaded ordjmf.jar (cust_datasourcesink) from oracle. I added the download path to my classpath variable and registered it to JFM by adding and commiting 'oracle.ord' both for protocol and content prefix in the JMF Registry Editor. Is there any way to test, if it's correctly registered?
      Does anybody could help me?

      Thanks Christian
        • 1. Re: display video using JMF
          156916
          Do you have the latest version?

          The setup instructions on the README page seem to be different than what I see in your example...

          http://otn.oracle.com/software/products/intermedia/htdocs/descriptions/jmf.html
          http://otn.oracle.com/software/products/intermedia/files/jmf/cust_datasourcesink_readme.html

          You need a ordjmf.properties file.

          Once configured, use JMStudio from http://java.sun.com/jmf to test if you have configured correctly....

          Larry
          • 2. Re: display video using JMF
            408764
            The example I referred to is this one: http://otn.oracle.com/products/intermedia/pdf/imedia_doc_twp.pdf (page 9/10) Maybe it is for an older version.
            But I tried the orders from the README too. I created a procedure
            getvideo_by_id
            (
            video out blob,
            mimetyp out varchar2,
            videoid in number)
            as
            begin
            select t.video.getContent(), t.video.getMimeType()
            into video, mimetyp
            from videodemo t
            where t.video_id = videoid;
            end;
            in schema scott.

            My ordjmf.properties looks like this
            user=scott
            password=tiger
            url=jdbc:oracle.oci:@TestDB
            getVideoByID=getvideo_by_id

            and it's path is added to my classpath variable.
            TestDB ist part of my tnsnames.ora.

            If I try to open the url "im://retrieval/getVideoByID/1" with JMStudio I get this message: "Could not create player for im://retrieval/getVideoByID/1".
            Using this URL in my java program in the MediaLocator Constructor I still get
            javax.media.NoDataSourceException: Cannot find a DataSource for: im://retrieval/getVideoByID/1
                 at javax.media.Manager.createDataSource(Manager.java:1037)
                 at intermediatest.InterMediaTest.playVideo(InterMediaTest.java:279)
                 at intermediatest.InterMediaTest.main(InterMediaTest.java:48)
            when he tries to create the data source.
            • 3. Re: display video using JMF
              156916
              Did you try the new version of ordjmf.jar file as well?

              You can download it easily from http://otn.oracle.com/software/products/intermedia/index.html

              I would make sure you followed the steps correctly, and that the classpath that you configure with and run with are the same.

              1) Download ordjmf.jar and place it in your classpath
              2) Start JMFRegistry executable Add "oracle.ord" into both your "protocol Prefix List" and "Content Prefix List" in your PackageManager tab, then commit on both.
              3) Create ordjmf.properties file as per instructions.

              Works fine with me...

              Larry
              • 4. Re: display video using JMF
                408764
                I did all of this.
                To make sure, that JMStudio uses the correct classpath I unzipped the jmf.jar from the JFM distrubtion. After, I went to this directory and started JMStudio by
                java -classpath ".;d:\PROGRA~2\jmf2_1_1\lib\sound.jar;d:\PROGRA~2\jmf2_1_1\lib\jmf.jar;d:\PROGRA~2\jmf2_1_1\lib;.;%systemroot%\java\classes;d:\PROGRA~2\jmf2_1_1\Plugins\ordjmf.jar;d:\PROGRA~2\jmf2_1_1\Plugins\MPEG4VideoDecoderEval.zip;d:\oracle\oracle92\user;D:\oracle\oracle92\jdbc\lib\classes12.zip;D:\oracle\oracle92\ord\jlib\ordim.zip;D:\oracle\oracle92\sqlj\lib\runtime11.zip" JMStudio.

                I think that my classpath should include all important classes. My "ordjmf.properties" is located in "d:\oracle\oracle92\user". When I try to open the url "im://retrieval/getVideoByID/1" I get the following output:
                DB connecting error: java.sql.SQLException: No suitable driver
                java.io.IOException
                DB connecting error: java.sql.SQLException: No suitable driver
                java.io.IOException
                UNABLE_CREATE_PLAYERjavax.media.NoPlayerException: Error instantiating class:
                oracle.ord.media.protocol.im.DataSource : java.io.IOException

                Maybe this output helps to find out my problem.

                Christian
                • 5. Re: display video using JMF
                  156916
                  OK, that is better information.

                  It looks like there is a problem using the JDBC driver.

                  Can I see your ordjmf.properties file?

                  Thee url property should look like:

                  url=jdbc:oracle:thin:@myhost.myco.com:1521:orcl

                  Without quotes(")

                  Larry

                  • 6. Re: display video using JMF
                    408764
                    Hi,
                    I had a mistake in my ordjmf.properties-file. Instead of
                    url=jdbc:oracle:oci:@TestDB I had written
                    url=jdbc:oracle.oci:@TestDB
                    Now JMStudio works fine, if I start it with my own classpath. It seems as it would over write the classpath of Win2000.
                    If I start the following program, I only have one problem yet. I can hear the sound, but I can't see the video. Probably it's very easy to fix.

                    import java.io.*;
                    import java.sql.*;
                    import oracle.sql.*;
                    import oracle.jdbc.driver.*;
                    import oracle.ord.im.*;
                    import javax.media.*;
                    import javax.media.control.TrackControl;
                    import javax.media.Format;
                    import javax.media.format.*;
                    import javax.media.protocol.*;
                    import javax.media.datasink.*;
                    import java.awt.*;

                    public class VideoTest extends Frame {

                    public VideoTest() {
                    super ("Videotest");
                    this.setSize(800,600);
                    }

                    public static void main(String[] args) {
                    VideoTest videoTest1 = new VideoTest();
                    videoTest1.show();
                    try {
                    videoTest1.playVideo();
                    }
                    catch (Exception exc) {
                    exc.printStackTrace();
                    }
                    }

                    private void playVideo () throws SQLException, Exception {
                    MediaLocator locator = new
                    MediaLocator ("im://retrieval/getVideoByID/2");
                    DataSource source = Manager.createDataSource(locator);
                    Player player = Manager.createPlayer(source);
                    player.start();
                    }
                    }

                    I can't add the player to my Frame and it doesn't have a show method. So how can I show it?

                    Thanks Christian
                    • 7. Re: display video using JMF
                      156916
                      This is best asked int Sun's JMF forum....

                      jmf-interest@java.sun.com

                      I am sure there will be better experts there...

                      Archives:
                      http://archives.java.sun.com/archives/jmf-interest.html

                      Larry
                      • 8. Re: display video using JMF
                        156916
                        This question is best asked the the jmf-interest list.

                        The forum can be found at:

                        http://archives.java.sun.com/cgi-bin/wa?A0=jmf-interest

                        http://java.sun.com/products/java-media/jmf/support.html

                        Larry
                        • 9. Re: display video using JMF
                          408764
                          Hi,
                          finally I succeeded in displaying my video. Thanks. But I still have a question.
                          Is there a way to get the multimedia content out of database without to create procedures in database? Sometimes this isn't really convenient. In http://otn.oracle.com/products/intermedia/pdf/imedia_doc_twp.pdf (page 9/10) it is described, but it doesn't work for me. There a SQL statement is added to the connect string. The error message is
                          "java.io.IOException: no information about the query specified"
                          when he tries to create a DataSource. I Used exactly the string, which was given there.

                          Thanks, Christian
                          • 10. Re: display video using JMF
                            156916
                            A procedure is required in the new implementation of the Realserver Plugin.

                            However, theoretically (I never tried this myself) you should be able to use Dynamic sql for your query, (

                            http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/11_dynam.htm#12701 )so you should be able to pass in

                            a SQL select statement,

                            CREATE OR REPLACE PROCEDURE dynGetVideoForRetrieval(
                            myVideoLob OUT BLOB,
                            myMimeType OUT VARCHAR2,
                            mySelect IN VARCHAR2)
                            AS
                            BEGIN
                            Execute Immediate mySelect into myMimeType, myVideoLob;
                            END;

                            I am not sure if you would need to escape things in the SQL statement of your media URL or not (like %20 for spaces?)

                            You could also create a select from other things passed in like perhaps Table name, column name and where clause...

                            Larry
                            • 11. Re: display video using JMF
                              408764
                              OK, thanks. I'll try it.
                              • 12. Re: display video using JMF
                                771845
                                Hi EveryBody!!
                                I anloy start to learn JMF.
                                Can you give me link to download ordjmf.jar? I didn't see it anywhere.
                                • 13. Re: display video using JMF
                                  759167
                                  Im not sure but look here :
                                  http://java.sun.com/javase/technologies/desktop/media/jmf/index.jsp
                                  There is a jmf.jar i dont know if it is the same or not.
                                  But it worth a try.