Java Application + Flash / Win Media Player.

Hey Guys,
I am developing a video streaming application and wanted to integrate the Flash player in my code. I am not able to do it. I could load and open the player but couldnt play .swf file. Please advice / suggest / guide...
Bye,
Salil.Siddhaye

Following is the sample code that I am trying to execute..by calling the Win Media Player
public static void main(String[] args)
          String cmd = "C:\\Program Files\\Windows Media Player\\wmplayer.exe";
          try
               Process p = Runtime.getRuntime().exec(cmd);
               OutputStream out = p.getOutputStream();
               RandomAccessFile file = new RandomAccessFile("C:\\sample.wmv", "r");
//               ByteBuffer buffer = ByteBuffer.allocate(SystemInfo.getInstance().getSizeOfChunk());
               ByteBuffer buffer = ByteBuffer.allocate(200);
               FileChannel channel = file.getChannel();
               int n = 0;
               int i = 0;
               while ((n = channel.read(buffer)) >= 0)
                    byte[] b = new byte[buffer.array().length];
                    try
                         out.write(b);
                         out.flush();
                         System.out.println(b.length+" bytes flushed()");
                         Thread.sleep(7000);
                         //just to see if the playback stops due unavailability of data.
                    catch (Exception e)
                         e.printStackTrace();
          catch(IOException e)
               System.out.println("Error : " + e + "\n");
     }

Similar Messages

  • Win Media Player from JMF...

    Hi,
    I am new to JMF. I am currently developing a p2p based video streaming project and would like to invoke Win Media Player or Flash Movie Playre from the Java app..
    Pleasen help / advice / suggest...
    Thank you.
    Salil.Siddhaye

    this code may help it is sun sample code
    * @(#)SimplePlayerApplet.java     1.2 01/03/13
    * Copyright (c) 1996-2001 Sun Microsystems, Inc. All Rights Reserved.
    * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
    * modify and redistribute this software in source and binary code form,
    * provided that i) this copyright notice and license appear on all copies of
    * the software; and ii) Licensee does not utilize the software in a manner
    * which is disparaging to Sun.
    * This software is provided "AS IS," without a warranty of any kind. ALL
    * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
    * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
    * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
    * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
    * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
    * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
    * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
    * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
    * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
    * POSSIBILITY OF SUCH DAMAGES.
    * This software is not designed or intended for use in on-line control of
    * aircraft, air traffic, aircraft navigation or aircraft communications; or in
    * the design, construction, operation or maintenance of any nuclear
    * facility. Licensee represents and warrants that it will not use or
    * redistribute the Software for such purposes.
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.String;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.IOException;
    import java.util.Properties;
    import javax.media.*;
    //import com.sun.media.util.JMFSecurity;
    * This is a Java Applet that demonstrates how to create a simple
    * media player with a media event listener. It will play the
    * media clip right away and continuously loop.
    * <!-- Sample HTML
    * <applet code=SimplePlayerApplet width=320 height=300>
    * <param name=file value="sun.avi">
    * </applet>
    * -->
    public class SimplePlayerApplet extends Applet implements ControllerListener {
    // media Player
    Player player = null;
    // component in which video is playing
    Component visualComponent = null;
    // controls gain, position, start, stop
    Component controlComponent = null;
    // displays progress during download
    Component progressBar = null;
    boolean firstTime = true;
    long CachingSize = 0L;
    Panel panel = null;
    int controlPanelHeight = 0;
    int videoWidth = 0;
    int videoHeight = 0;
    * Read the applet file parameter and create the media
    * player.
    public void init() {
         //$ System.out.println("Applet.init() is called");
         setLayout(null);
         setBackground(Color.white);
         panel = new Panel();
         panel.setLayout( null );
         add(panel);
         panel.setBounds(0, 0, 320, 240);
         // input file name from html param
         String mediaFile = "The Departed CD1.avi";
         // URL for our media file
         MediaLocator mrl = null;
         URL url = null;
         // Get the media filename info.
         // The applet tag should contain the path to the
         // source media file, relative to the html page.
         if ((mediaFile = getParameter("FILE")) == null)
         Fatal("Invalid media file parameter");
         try {
         url = new URL(getDocumentBase(), mediaFile);
         mediaFile = url.toExternalForm();
         } catch (MalformedURLException mue) {
         try {
         // Create a media locator from the file name
         if ((mrl = new MediaLocator(mediaFile)) == null)
              Fatal("Can't build URL for " + mediaFile);
         try {
              JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager,
                                  JMFSecurity.writePropArgs);
              JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager,
                                  JMFSecurity.readPropArgs);
              JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager,
                                  JMFSecurity.connectArgs);
         } catch (Exception e) {}
         // Create an instance of a player for this media
         try {
              player = Manager.createPlayer(mrl);
         } catch (NoPlayerException e) {
              System.out.println(e);
              Fatal("Could not create player for " + mrl);
         // Add ourselves as a listener for a player's events
         player.addControllerListener(this);
         } catch (MalformedURLException e) {
         Fatal("Invalid media file URL!");
         } catch (IOException e) {
         Fatal("IO exception creating player for " + mrl);
         // This applet assumes that its start() calls
         // player.start(). This causes the player to become
         // realized. Once realized, the applet will get
         // the visual and control panel components and add
         // them to the Applet. These components are not added
         // during init() because they are long operations that
         // would make us appear unresposive to the user.
    * Start media file playback. This function is called the
    * first time that the Applet runs and every
    * time the user re-enters the page.
    public void start() {
         //$ System.out.println("Applet.start() is called");
    // Call start() to prefetch and start the player.
    if (player != null)
         player.start();
    * Stop media file playback and release resource before
    * leaving the page.
    public void stop() {
         //$ System.out.println("Applet.stop() is called");
    if (player != null) {
    player.stop();
    player.deallocate();
    public void destroy() {
         //$ System.out.println("Applet.destroy() is called");
         player.close();
    * This controllerUpdate function must be defined in order to
    * implement a ControllerListener interface. This
    * function will be called whenever there is a media event
    public synchronized void controllerUpdate(ControllerEvent event) {
         // If we're getting messages from a dead player,
         // just leave
         if (player == null)
         return;
         // When the player is Realized, get the visual
         // and control components and add them to the Applet
         if (event instanceof RealizeCompleteEvent) {
         if (progressBar != null) {
              panel.remove(progressBar);
              progressBar = null;
         int width = 320;
         int height = 0;
         if (controlComponent == null)
              if (( controlComponent =
              player.getControlPanelComponent()) != null) {
              controlPanelHeight = controlComponent.getPreferredSize().height;
              panel.add(controlComponent);
              height += controlPanelHeight;
         if (visualComponent == null)
              if (( visualComponent =
              player.getVisualComponent())!= null) {
              panel.add(visualComponent);
              Dimension videoSize = visualComponent.getPreferredSize();
              videoWidth = videoSize.width;
              videoHeight = videoSize.height;
              width = videoWidth;
              height += videoHeight;
              visualComponent.setBounds(0, 0, videoWidth, videoHeight);
         panel.setBounds(0, 0, width, height);
         if (controlComponent != null) {
              controlComponent.setBounds(0, videoHeight,
                             width, controlPanelHeight);
              controlComponent.invalidate();
         } else if (event instanceof CachingControlEvent) {
         if (player.getState() > Controller.Realizing)
              return;
         // Put a progress bar up when downloading starts,
         // take it down when downloading ends.
         CachingControlEvent e = (CachingControlEvent) event;
         CachingControl cc = e.getCachingControl();
         // Add the bar if not already there ...
         if (progressBar == null) {
         if ((progressBar = cc.getControlComponent()) != null) {
              panel.add(progressBar);
              panel.setSize(progressBar.getPreferredSize());
              validate();
         } else if (event instanceof EndOfMediaEvent) {
         // We've reached the end of the media; rewind and
         // start over
         player.setMediaTime(new Time(0));
         player.start();
         } else if (event instanceof ControllerErrorEvent) {
         // Tell TypicalPlayerApplet.start() to call it a day
         player = null;
         Fatal(((ControllerErrorEvent)event).getMessage());
    } else if (event instanceof ControllerClosedEvent) {
         panel.removeAll();
    void Fatal (String s) {
         // Applications will make various choices about what
         // to do here. We print a message
         System.err.println("FATAL ERROR: " + s);
         throw new Error(s); // Invoke the uncaught exception
                   // handler System.exit() is another
                   // choice.
    take care add the video to the same path where the code is saved
    hope that will help you

  • Firefox 6.0 w/ win media player plugin 1.0.0.8 enabled ALWAYS asks if I want to open a .wmv file with Win Media Player.

    Firefox 6.0 would not open .wmv files, so I downloaded and installed M/S windows media player firefox plugin, ver 1.0.0.8.
    I have checked using the plugin mgr that it is installed and enabled, but firefox still will not open .wmv files - It still brings up a window asking if I want to use Win Media Player to open the file.

    Flash Player.plugin 0x1a89d53e FlashPlayer_10_0_45_2_FlashPlayer +
    You have an outdated version of Flash installed.
    Uninstall the current copy of Flash then reinstall, instructions here.
    http://kb2.adobe.com/cps/865/cpsid_86551.html#ostype=m,prob1=fnctn,prob2=game,
    And, you have the Community Toolbar installed. That has to go.
    /Library/Application Support/Conduit/Plugins/cttoolbar.bundle/Contents/Resources/Services/ct_alerts. bundle/Contents/MacOS/ct_alerts
    /Library/Application Support/Conduit/Plugins/cttoolbar.bundle/Contents/MacOS/ct_plugins
    /Library/InputManagers/CTLoader/ct_loader.bundle/Contents/MacOS/ct_loader
    /Library/ScriptingAdditions/ct_scripting.osax/Contents/MacOS/ct_scripting
    Open a Finder window then select MacintoshHD in the Sidebar on the left. Then open the LIbrary folder then the Application Support folder, the Input Managers folder and the Scripting Additions folder.
    Move all the files above in bold print to the Trash.
    Relaunch Safari after you have re installed Flash and deleted all those files.

  • MP3 plays fine in Win Media Player, but won't import in iTunes

    I have this MP3 file in a folder on my hard drive. It plays fine in Win Media Player.
    If I "Add the Folder to Library" all other MP3 files in the folder come though fine but this one is left behind.
    If I use "Add File to Library" there is just a screen "flicker" but the file is not added.
    What could cause this? and how do I get the file into iTunes?
    TIA
    Gert
    Windows XP SP2

    Are you certain that the files in question are in fact MP3 files and not some other format?
    iTunes can play plain old MP3 files, but it cannot play proprietary schemes with digital rights management built in, and it cannot play WMA files.

  • Steps involved in writing java application on win CE

    I want to develop a java application in win CE platform for a handheld device.
    1. What are all the steps involved.
    2. Is there any simulator available for win CE so that I can run my java application.
    Advance thanks,
    Regards,
    Balasubramaniam.K.R
    [email protected]

    The way I developed my first app for the Compaq iPAQ
    1. Install PersonalJava
    2. Build app using AWT classes only (although I think SWING can be used)
    3. Screen size 240 x 295 (thats what I used)
    4. Compile and run on PC
    5. Move to PPC (fingers crossed)
    6. You may want to add an app.LNK file (kinda like a *.bat file) to setup classpath and file args
    Sun has a compatibility suite you can run against your app to make sure it is PJava compliant. http://java.sun.com/products/personaljava/javacheck.html
    Also make sure you don't use classes/methods that aren't supported
    There is a PJava emulkation environment, but I never used it.
    http://java.sun.com/products/personaljava/pj-emulation.html
    ...good luck

  • R there any neg. recommendations re dwnloading Win Media Player/Real Player on my MacB w/OSX.8.2

    I am Preparing to sign-in to a live presentation in a couple of days. The presenting org's s/w recommends I add Real Player and/or WinMedia Player.  I'm guessing o.k. w/no problem, but just checking it out.  Txs in advance for + or - rpts from your experience.
    greenegg

    RealPlayer is ok as well as Flip4Mac which is the Mac equivalent to Win Media Player. 

  • Flash player and Win media player for iphone 3G?

    There's any way to download an iphone 3G version of Flash player and Window media player. I am trying to hear a radio station on a web site but need those plugins to hear it. (www.lax.fm)
    Please let me know.
    Angel
    Message was edited by: Mundy KalEl

    No. You cannot download or install anything to iphone, unless it is offered in the App Store on itunes.
    Adobe does not make a flash player for iphone.

  • HMC150 Footage ok in PProCS4, but grey when viewing via Win Media Player

    I just purchased an HMC150 and really like it and I am recording in 1080P 24 and pulling it into a 1080P/24 timeline.  I can edit and view the media no problem in Premiere with full color, but if I play the original raw AVCHD original files through Windows Media Player the video is Grey and if I export them from PPro to MPeg2 they are also grey...anybody have any ideas why this would be or how to correct it?

    Good question, sorry I should have included all of that information.
    I am running on an HPZ800 dual quad core with 36GB of RAM using PPRo CS4 (latest version) on Windows 64 bit.  I am not exactly sure which codec is going to be used in this case because I believe that there are 3 possible ones that could be used.  It appears that PPro is using it's own AVCHD codec which is probably why it works fine.  Windows 7 natively recognizes AVCHD, but I have two utilities installed on my system to download content from my cameras that may have also installed Codec's.  The first is one from Canon that comes with their camera's (in this case the HV30, that downloads AVCHD also), and the 2nd is the AVCCam application that comes with the Panasonic HMC150 to download content from that camera.  The AVCHD files from my Canon play just fine through Windows Media Player or Premiere Pro, but the HMC150 files only play in full color in Premiere Pro, not through Windows Media Player.  I agree it might be codec related, but not exactly sure the best way to track down the problem.  Thanks in advance for the help.

  • How to use win media player in streaming

    Hi all
    I want to do an application that is streaming live video on network and playable from windows media player on client side. Is this possible with JMF? Or how can I do this with another way?

    wpafbuser1 wrote:
    Is this possible with JMF? Yes.but how ?

  • Win Media Player after 10.4.3

    Hello
    After the 10.4.3 update my Windows media player refuses to start, and I get this message on my screen "The application Windows Media Player quit unexpectedly".
    Does anyone have this problem, I have already verified my disk permissions but the problem persists...
    If any one have this handled let me know!
    Thanks to you ALL

    Im no computer genius mate but i also have windows media player on my 10.4.3 and it works perfectly...no problem at all! im guessing you should un-install it and then re-install...but then again, i dont even know how to un-install on macs...im new!
    cheers

  • Cannot run java application in Win XP

    I worte a java application(a Swing app), I test it and run under win NT, it works fine for me.
    Then I recompile it in my WinXP using j2sdk1.4.1_02, run it in a command prompt, but it does NOT start up the application, I check the window task manager, a java.exe already startup and it eat up 100% CPU of my XP, but the application never been startup.
    My Swing application is not a JApplet but a JFrame.
    Does anyone have the similiar problem?
    Thx in advance
    Henry

    Try adjusting your path settings to stop using the MS VM (did you recently use win update?):
    My Computer->Properties -> Advanced -> Environment Variables
    System Variables -> "Path"
    If it currently starts with:
    %SystemRoot%\system32;...
    change it to:
    .;%JAVA_HOME%\bin;%SystemRoot%\system32;...
    If you haven't set JAVA_HOME, create a new variable like:
    JAVA_HOME = C:\j2sdk1.4.1_02
    Note that using the ".;" before path makes the current dir's executables take prevalence over a same-named executable in a subsequent path.
    Putting "%JAVA_HOME%\bin" before "%SystemRoot%\system32" makes certain that the current java.exe gets used (not Micro$oft's java.exe)
    Try it, hope it helps,
    Georg.

  • Can't update win media player plugin 3.0.2.628

    I did a Plugin check of my ff Plugins and was notified that Windows Media Player Plug-in Dynamic Link Library (3.0.2.628) Npdsplay dll needs to be updated. When I click on the update tab, nothing happens. How can I update this plugin? Thanks.

    I did a Plugin check of my ff Plugins and was notified that Windows Media Player Plug-in Dynamic Link Library (3.0.2.628) Npdsplay dll needs to be updated. When I click on the update tab, nothing happens. How can I update this plugin? Thanks.

  • Plays in Win Media Player, but won't import in iTunes

    I have some quite large MP3 files that play fine in Windows Media Player, but I iTunes won't import them.
    What could be reason for that?
    TIA
    Gert
    iTunes 6 Windows XP
    iTunes 6   Windows XP  

    Are you certain that the files in question are in fact MP3 files and not some other format?
    iTunes can play plain old MP3 files, but it cannot play proprietary schemes with digital rights management built in, and it cannot play WMA files.

  • BB Link not linking to Win Media Player or iTunes

    Out of the blue, my BB Link will not show my music library in iTunes or Windows Media Player.
    I'm using version 1.0.0.76 and have even reinstalled BB Link.
    I tried with WMP and iTunes closed and open.
    It worked a few days ago now I'm having no luck - very unusual.
    I'm trying to sync my Z10 and Playbook.
    HELP!!! I'm tired of having problems with BB!!!

    Hey cdawaters,
    Welcome to the BlackBerry Support Community Forums.
    Thanks for the question.
    Do you get any specific errors when you try to synchronize the media?  Also are you using a PC or Mac?
    Also have you tried uninstalling BlackBerry Link and re-installing it?
    I look forward to your reply.
    Cheers.
    -ViciousFerret
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Like! for those who have helped you.
    Click  Accept as Solution for posts that have solved your issue(s)!

  • Getting rid of application of windows media player

    My husband downloaded the windows media player and it will not erase, i put it into the trash but whenever i try to delete it it says it cant be deleted because it is locked. I went to the get info and the program does not appear to be locked.......HELP!

    Thank you so much....I have hated that darn thing for months..How does that work exactly?
    Now another question i have a window that pops all the time randomly stating that keychain has changed and it asks me if i want to change all. some of the examples dotmac...system.....HELP

Maybe you are looking for

  • Some users not seeing all of a web form in Smart View Excel 11.1.2?

    I am on Planning 11.1.2 and I have an end user who, when he opens a web form in Excel using Smart View, he only sees about 1/3 of the entire form. If in the Oracle/Planning web, the form is fine. When he uses my machine, he sees the entire web form i

  • How to view only specific authentication requests in access tracker

    Requirement: How to view only "Healthy/Unhealthy" requests from a specific Webauth service. Solution: If we have more than one Webauth service (based on conditions such as Device type or NAS IP or posture status etc) and we need only Healthy/Unhealth

  • Report Painter - data not shown at first selection

    Hello, we have a Report Painter report for cost centers. If we start the report with normal selection the values of the cost centers are not shown at the first look. The window on the right side only shows the sum for the whole cost center group, but

  • Issues with this website

    Is this a Safari issue or a Dice issue, or both? http://community.dice.com/t5/Customer-Support/Using-Safari-with-this-website/td- p/191198 My post The font size is WAY WAY too small, and I have had some other issues as well. One of which is when I cl

  • SUS PO Response date

    Hi Experts ! When suppliers are on purchase order response and wants to reject item having a "Confirmed For" date in past, the system gives an error - Delivery date not possible; check your entry They are forced to set the confirmed for date and send