java media palyer

Page 1 of 1

2 Replies - 710 Views - Last Post: 06 May 2011 - 06:52 AM Rate Topic: -----

#1 mohd_faraz   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-May 11

java media palyer

Posted 06 May 2011 - 06:50 AM

sir i have creted my media player using java but i provide additional
capablities subtitle integration,
but media player download subtitle but could not play on screen
pls what code i use to display the subtitle on scrren
sir pls reply fast
i will submitted this project on 12 may 2011


sir what can i do for run a program
i did not understand what u say in reply


<code>

/*Demonstrating the Java Media Player*/

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.media.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.Toolkit;
//private File file;

public class media1 extends JFrame
{
private Player player;
private File file;
JFrame frame1 = new JFrame();
JFrame frame2=new JFrame();
JPanel ppp=new JPanel();
int i=0;

public media1()
{
super( "Blitz...The Java Media Player" );

//JButton openFile = new JButton( "Open file" );
//JButton video = new JButton( "video" );


JMenu menu1 = new JMenu("Media");
JMenuItem jj=menu1.add(new JMenuItem("open-file"));
menu1.add(new JSeparator());
JMenuItem jb=menu1.add(new JMenuItem("Playlist"));
menu1.add(new JSeparator());
//menu1.add(new JMenuItem("Q"));
//menu1.add(new JMenuItem("c"));
//menu1.add(new JSeparator());
JMenuItem jc=menu1.add(new JMenuItem("QUIT"));

JMenu menu2 = new JMenu("Playback");
menu2.add(new JMenuItem("previous"));
menu2.add(new JSeparator());
menu2.add(new JMenuItem("next"));
menu2.add(new JSeparator());
JMenuItem jd=menu2.add(new JMenuItem("snapshot"));

ppp.setLayout (new BoxLayout(ppp, BoxLayout.Y_AXIS));
JMenu menu3 = new JMenu("Video");
JMenuItem je=menu3.add(new JMenuItem("Fullscreen"));
menu3.add(new JSeparator());
menu3.add(new JMenuItem("Zoom"));
menu3.add(new JSeparator());
JMenuItem tata=menu3.add(new JMenuItem("Subtitle"));
tata.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
new com.jsub.jony.gui.JSubFrame(file.toString()).setVisible(true);
}
});


frame2.setTitle("Playlist");
JMenuBar bar = new JMenuBar();
bar.add(menu1);
bar.add(menu2);
bar.add(menu3);
JFrame frame = new JFrame();
setJMenuBar(bar);
setSize(300,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);


jj.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
openFile();
//removePreviousPlayer();
createPlayer();
}
});
jb.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
openFile();
playlist1();
}
});
jc.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
System.exit(0);
}
});
jd.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
snap();
}
});
je.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
setLocation(0,0);
setSize(2000,768);
}
});

//frame.show();
}


private void snap()
{
try {
//int[] Ex = new int[24];

Robot robot = new Robot();
BufferedImage [] bi=new BufferedImage[10];
// Capture the screen shot of the area of the screen defined by
the rectangle
bi[i]=robot.createScreenCapture(new
Rectangle((Toolkit.getDefaultToolkit().getScreenSize())));
ImageIO.write(bi[i], "jpg", new File("d:/imageTest"+i+".jpg"));
i++;
//ImageIO.write(bi, "jpg", new File("d:/imageTest1.jpg"));

} catch (AWTException e1) {
e1.printStackTrace();
}
catch (IOException e1) {
e1.printStackTrace();
}
}



private void openFile()
{
JFileChooser fileChooser = new JFileChooser();

fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
int result = fileChooser.showOpenDialog( this );

if ( result == JFileChooser.CANCEL_OPTION )
file = null;
else
file = fileChooser.getSelectedFile();
}


private void playlist1()
{

final JButton l1, l2,l3;
l1 = new JButton(file.toString());
if (ppp!=null)
frame2.remove(ppp);
ppp.add(l1);
l1.addActionListener(new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
file=new File(l1.getText());
createPlayer();
}
});
ppp.add(Box.createVerticalGlue()); // This will expand/contract as needed.
frame2.add(ppp);
frame2.pack();
frame2.setVisible(true);
}


private void createPlayer()
{
if ( file == null )
return;

removePreviousPlayer();

try
{
// create a new player and add listener
player = Manager.createPlayer( file.toURL() );
player.addControllerListener( new EventHandler() );
player.start(); // start player
}
catch ( Exception e )
{
JOptionPane.showMessageDialog( this, "Invalid file or location",
"Error loading file",
JOptionPane.ERROR_MESSAGE );
}
}


private void removePreviousPlayer()
{
if ( player == null )
return;



Component visual = player.getVisualComponent();
Component control = player.getControlPanelComponent();

Container c = getContentPane();

if ( visual != null )
c.remove( visual );

if ( control != null )
c.remove( control );player.close();
}


public static void main(String args[])
{
media1 app = new media1();

app.addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
System.exit(0);
}
});
}



// inner class to handler events from media player

private class EventHandler implements ControllerListener
{
public void controllerUpdate( ControllerEvent e )
{
if ( e instanceof RealizeCompleteEvent )
{
Container c = getContentPane();

// load Visual and Control components if they exist
Component visualComponent = player.getVisualComponent();

if ( visualComponent != null )
c.add( visualComponent, BorderLayout.CENTER );

Component controlsComponent = player.getControlPanelComponent();

if ( controlsComponent != null )
c.add( controlsComponent, BorderLayout.SOUTH );

c.doLayout();
}
}
}
}
</code>

Is This A Good Question/Topic? 0
  • +

Replies To: java media palyer

#2 nick2price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 565
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: java media palyer

Posted 06 May 2011 - 06:52 AM

Seriously, stop posting the same question
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: java media palyer

Posted 06 May 2011 - 06:52 AM

This is the third duplicate thread you have opened. STOP IT!

Also, USE CODE TAGS!!! Like so: :code:.

Duplicate thread closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1