ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Java J2EE  >>  Java Related  >>  Swing
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
I want to use the markerfor playing a video using the 
jmf.Suppose my video length is of 2 hours.I want it to play 
ex-15 mintue or 20 mintue and should stop after assigning 
the time.I am providing my piece of code............please 
help me....
package com.jha.cdac.lila.praveen;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.URL;

import javax.media.ControllerAdapter;
import javax.media.Manager;


/**
 *
 * @author vinays
 */
import javax.media.Player;
import javax.media.RealizeCompleteEvent;
import javax.media.Time;
import javax.swing.JFrame;
public class PlayVideo extends javax.swing.JFrame{

    Player player;
    Component center;
    Component south;



// this code is required for playing the video file of 
mpeg,mp4,mp3,3gp,rm,flv,
    //wmf,mpv,vob,qt and the asf extension
      public PlayVideo() {
      
     File file = new File("Lesson1.mpg");
      
        try {
           load(file);
          //  load()
        }
        catch (Exception ex) {
            //Logger.getLogger(LessonNarrative.class.getName
()).log(Level.SEVERE, null, ex);
            System.out.println("Error while loading 
file............"+ex);
        }
      }
      

    //the piece of code given below is used to load the 
file which user want to play.
    public void load(final File file) //load the file
        throws Exception {    
      URL url = file.toURL();
      final Container contentPane =
        getContentPane();
      if (player != null) {

          player.stop();

      }
      // MediaLocator mediaLocator=new MediaLocator
(file.toURL());
     //  DataSource dataSource=Manager.createDataSource
(mediaLocator);
    //   player=Manager.createPlayer(url);
    player = Manager.createRealizedPlayer(url);
       ControllerAdapter listener = new ControllerAdapter() 
{
            @Override
            public void realizeComplete(
            RealizeCompleteEvent event) {
            Component vc =   player.getVisualComponent();
           player.getVisualComponent();
          if (vc != null) {
            contentPane.add(vc,
              BorderLayout.CENTER);
            center = vc;
          } else {
            if (center != null) {
              contentPane.remove(center);
              
              contentPane.validate();
            }
          }
          Component cpc = player.getControlPanelComponent();
          if (cpc != null) {
            contentPane.add(cpc,
              BorderLayout.SOUTH);
            south=cpc;
          } else
          {
            if (south != null) {
              contentPane.remove(south);
              contentPane.validate();
            }
          }
          pack();
//          //setTitle(file.getName());   //to get the 
title of Video or Audio File
       }
      };
       
   
   
   
 Time tm=new Time(30.4402403);
 Time tm1=new Time(5.7256199);
      player.addControllerListener(listener);
      player.setMediaTime(tm1);


       player.setStopTime(tm);
    // player.setMediaTime(new Time(5.0));
     //player.setStopTime(new Time(73));
      player.realize();
      player.start();


       
           }

    public static void main(String args[]) throws 
ClassNotFoundException {
      PlayVideo pv = new PlayVideo();
      
      JFrame f = new JFrame("Lesson1");
       f.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) { 
System.exit(0); }
        });
        f.getContentPane().add("Center", pv);
        f.pack();
     Dimension screenSize = Toolkit.getDefaultToolkit
().getScreenSize();
        int w = 420;
        int h = 140;
        pv.setLocation(screenSize.width/2 - w/2, 
screenSize.height/2 - h/2);
        pv.setSize(w, h);
        pv.setVisible(true);
 }


No Answer is Posted For this Question

Be the First to Post Answer

 
 
 
Other Swing Interview Questions
 
  Question Asked @ Answers
 
What are all the components used in Swing?  1
how can u handle runtime exceptions in java plz explain with examples briefly? Fujitsu2
what do u mean by GUI framework  1
What is the difference between AWT and Swing ? TCS1
Does Swing contains any heavy weight component?  4
What is JTable and what is its purpose?  3
What is the difference between AWT & Swing? Deshaw8
I want to change the appearance of Frame in Runtime, what class can be used to do this? Wipro1
How can you draw using Swing components?  1
What is meant by Swing?  4
when we right click on the JTable using mouse it works properly but how to right click on JTable in java using keyboard what should be the code for the same.....? Thanks Nitin  1
what is difference between checked and unchecked exception plz explain examples ? Fujitsu2
how to give transparency for JComboBox,JListBox and JTable TCS1
What is the corresponding Layout for Card in Swing? Patni2
Name the borders provided by Swing? Accenture1
can we create a object in static block class A { static { A a=new A(); } }  5
What is the use of JTree?  2
How are Swing and AWT be differentiated? Wipro2
What are tab pans?  3
what do u mean by GUI framework  1
 
For more Swing Interview Questions Click Here 
         
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com