javaflashappletalchemy

Impossible to do audio video with java applet?


This is the code I wrote in J2SE with Native java wrapper for Gstreamer. But alas it does not work in Web Browser, I am very upset what I can do now, I have no alternative to end this project.

IS it impossible to use audio/video with Java Applet for Gstreamer or To build a CD/DVD quality audio? (this is not targeted for world wide web, only web browsers between peer to peer or peer to 10 peer).

ex: working sample as j2SE but same code does not ever work with java applet from browser.

package audio;

/* Audio, Global class */
import org.gstreamer.*;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger; 

// Used via applet:
// <applet code="sipphone.MainApplet" width=600 height=600 archive="Audio.jar" >
public class MyGst
{

    public static void runit()
    {
        Gst.init();
        Pipeline pipe = new Pipeline("MyGst");
        Element src = ElementFactory.make("autoaudiosrc", "Source");
        Element sink = ElementFactory.make("autoaudiosink", "Destination");
        pipe.addMany(src, sink);
        src.link(sink);
        pipe.setState(State.PLAYING);

        Gst.main();
        pipe.setState(State.NULL);      
    }

}

Note: Follow up: In any web browser this native way works, when you have java. So JAVA applet works in any browser. Those who are like me, faced this problem, do not get confused.


Solution

  • If it works natively then there's always the option of creating a signed applet. That will allow you to have full native access, which I'm guessing is what the gstreamer stuff requires (it's probably loading the gstreamer native libraries at runtime).

    It'll be a little more annoying for users, as they'll have to grant it rights to run, and a little more annoying for you, as you'll have to sign the applet, but it should work.

    The other option is to see if there are any pure-Java audio streaming libraries that you could use in place of gstreamer. I can't speak to that, as I've never done anything more complicated with audio than playing an audio file, but they may exist.