本文整理汇总了Java中javax.media.Player.getVisualComponent方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getVisualComponent方法的具体用法?Java Player.getVisualComponent怎么用?Java Player.getVisualComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.Player
的用法示例。
在下文中一共展示了Player.getVisualComponent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MediaPlayer
import javax.media.Player; //导入方法依赖的package包/类
public MediaPlayer(URL mediauUrl) {
//initComponents();
setLayout(new BorderLayout());
try {
Player mediaPlayer = Manager.createRealizedPlayer(new MediaLocator(mediauUrl));
//setBackground(Color.BLACK);
//setLayout(null);
Component video = mediaPlayer.getVisualComponent();
//video.setBounds((this.getWidth() /2)+(860/3), (this.getHeight() /2), 720, 480);
if (video != null) {
add(video, BorderLayout.CENTER);
}
mediaPlayer.start();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
示例2: displayPlayer
import javax.media.Player; //导入方法依赖的package包/类
private void displayPlayer(Player p, MediaLocator ml) {
Component c = p.getVisualComponent();
if (c != null) {
add(new GridPanel(createBorder(ml), c));
invalidate();
}
}
示例3: PlayerPanel
import javax.media.Player; //导入方法依赖的package包/类
PlayerPanel(Player p) {
setLayout(new BorderLayout());
if ((vc = p.getVisualComponent()) != null)
add("Center", vc);
if ((cc = p.getControlPanelComponent()) != null)
add("South", cc);
}
示例4: MediaPanel
import javax.media.Player; //导入方法依赖的package包/类
public MediaPanel( URL mediaURL )
{
setLayout( new BorderLayout() ); // use a BorderLayout
// Use lightweight components for Swing compatibility
Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, 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
if ( controls != null )
add( controls, BorderLayout.SOUTH ); // add controls
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
}
示例5: controllerUpdate
import javax.media.Player; //导入方法依赖的package包/类
/**
* ControllerListener for the Players.
*/
public synchronized void controllerUpdate(ControllerEvent ce) {
Player p = (Player) ce.getSourceController();
if (p == null)
return;
// Get this when the internal players are realized.
if (ce instanceof RealizeCompleteEvent) {
p.start();
Component vc = p.getVisualComponent();
System.out.println("Start1.1" + vc);
if ( null != vc )
{
System.out.println("### visual component is " + vc);
JFrame aFrame = new JFrame("Video Frame");
JPanel aPanel = new JPanel();
aPanel.setBounds(0, 0, 176, 144);
aPanel.add(vc);
aFrame.add(aPanel);
aPanel.setBackground(Color.gray);
vc.setVisible(true);
aPanel.setVisible(true);
aFrame.setVisible(true);
aFrame.pack();
}
}
if (ce instanceof ControllerErrorEvent) {
p.removeControllerListener(this);
System.err.println("Receiver internal error: " + ce);
}
}
示例6: addScreen
import javax.media.Player; //导入方法依赖的package包/类
/**
* Create a JInternalFrame and add it to the desktop.
* The video component of Player is always displayed
* in this JInternalFrame if displayFlags & DISPLAY_VISUAL
* is true. The control panel component
* is displayed if displayFlags & DISPLAY_CONTROL is true.
*
* Player must be in Realized state so that visual and
* control components can be retieved.
*
* @param title
* Title displayed in JInternalFrame border.
* @param player
* A Player in the Realized state.
* @param displayFlags
* Flag which determines which AWT components
* associated with Player are diplayed.
*/
public void addScreen(String title,
Player player,
int displayFlags)
{
Debug.printObject("addScreen for " + title);
int displayCount = 0;
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setBorder(new EmptyBorder(0, 0, 0, 0));
if ((displayFlags & DISPLAY_VISUAL) != 0) {
Component vc = player.getVisualComponent();
if (vc != null) {
panel.add(vc, BorderLayout.CENTER);
displayCount++;
}
}
if ((displayFlags & DISPLAY_CONTROL) != 0) {
Component cp = player.getControlPanelComponent();
if (cp != null) {
panel.add(cp, BorderLayout.SOUTH);
displayCount++;
}
}
if (displayCount == 0)
return;
panel.validate();
panel.repaint();
ViewScreen screen = new ViewScreen(panel);
screen.setTitle(title);
screen.pack();
desktop.add(screen, JLayeredPane.PALETTE_LAYER);
desktop.validate();
hash.put(player, screen);
}