Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 10:10 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: [offer]What is JMF?!
PostPosted: Sat Feb 16, 2008 6:00 pm 
Offline
Expert
User avatar

Joined: Tue Nov 06, 2007 2:17 pm
Posts: 847
Has thanked: 0 time
Have thanks: 1 time

What is (JMF) ?

The Java Media Framework API (JMF) enables audio, video and other time-based media to be added to applications and applets built on Java technology. This optional package, which can capture, playback, stream, and transcode multiple media formats, extends the Java 2 Platform, Standard Edition (J2SE) for multimedia developers by providing a powerful toolkit to develop scalable, cross-platform technology.

I used (JMF) because, i needed it in my graduation project, i used it for playing videos and graping frames or seeking for a specific frame in a video , i will post the classes that helped me to learn this very powerful package beside the API Guide, and documentation, first let me put sun urls to get this package with API Guide and documentation: -

JMF 2.1.1e: http://java.sun.com/products/java-media/jmf/2.1.1/download.html
API Guide: http://java.sun.com/products/java-media/jmf/2.1.1/specdownload.html
Documentation:http://java.sun.com/products/java-media/jmf/2.1.1/documentation.html

Some Code examples i will start with easy one, and i will post the other classes in separate topics because they need quit explanation,

here its a simple class that show you the basics of jmf :

Code:

     import java.net.MalformedURLException;
     import java.net.URL;
     import javax.swing.JFileChooser;
     import javax.swing.JFrame;
   
     public class MediaTest
    {
       // launch the application
       public static void main( String args[] )
       {
          // create a file chooser
         JFileChooser fileChooser = new JFileChooser();
   
          // show open file dialog
         int result = fileChooser.showOpenDialog( null );
   
          if ( result == JFileChooser.APPROVE_OPTION ) // user chose a file
          {
             URL mediaURL = null;
   
             try
            {
               // get the file as URL
                mediaURL = fileChooser.getSelectedFile().toURL();
             } // end try
             catch ( MalformedURLException malformedURLException )
             {
               System.err.println( "Could not create URL for the file" );
             } // end catch

             if ( mediaURL != null ) // only display if there is a valid URL
             {
                JFrame mediaTest = new JFrame( "Media Tester" );
                mediaTest.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
   
                MediaPanel mediaPanel = new MediaPanel( mediaURL );
               mediaTest.add( mediaPanel );
   
                mediaTest.setSize( 300, 300 );
               mediaTest.setVisible( true );
             } // end inner if
          } // end outer if
       } // end main
   } // end class MediaTest


Code:


import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.net.URL;
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.Time;
import javax.media.format.VideoFormat;
import javax.swing.JPanel;

public class MediaPanel extends JPanel {

    public MediaPanel(URL mediaURL) {
        setLayout(new BorderLayout()); // use a BorderLayout

        // Use lightweight components for Swing compatibility
        Manager.setHint(Manager.MAX_SECURITY, true);

        try {
            // create a player to play the media specified in the URL
            Player mediaPlayer = Manager.createRealizedPlayer(mediaURL);

            // get the components for the video and the playback controls
            Component video = mediaPlayer.getVisualComponent();
            Component controls = mediaPlayer.getControlPanelComponent();

            if (video != null) {
                add(video, BorderLayout.CENTER);
            } // add video component
            VideoFormat vf = new VideoFormat(mediaURL.toString());
            String ff= vf.MJPG;
            System.out.println(ff);
            if (controls != null) {
                add(controls, BorderLayout.SOUTH);
            } // add controls
            Time m=mediaPlayer.getMediaTime();
            System.out.println(m.getSeconds());
           
            mediaPlayer.start(); // start playing the media clip
        } // end try
        catch (NoPlayerException noPlayerException) {
            System.err.println("No media player found");
        } // end catch
        catch (CannotRealizeException cannotRealizeException) {
            System.err.println("Could not realize media player");
        } // end catch
        catch (IOException iOException) {
            System.err.println("Error reading from the source");
        } // end catch
    } // end MediaPanel constructor

    } // end class MediaPanel


I hope that enough for today, and i will post the other classes as soon as possible, see ya

_________________
Any help needed just reply to my topic ,
ccna ,ccnp certified .


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: [offer]What is JMF?!
PostPosted: Sat Apr 05, 2008 8:21 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
Thank you casper for this post :gOOd:

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 job offer for Senior J2me developer
 job offer for c++ fresh graduated
 [offer] Class Video to jpg (JMF)
 Job offer: Lean Manager (Guangdong)
 offer a job
 [offer]How to set double fraction Precision

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Google Adsense [Bot] and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team