本文整理汇总了Java中javax.media.Player.addControllerListener方法的典型用法代码示例。如果您正苦于以下问题:Java Player.addControllerListener方法的具体用法?Java Player.addControllerListener怎么用?Java Player.addControllerListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.Player
的用法示例。
在下文中一共展示了Player.addControllerListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.media.Player; //导入方法依赖的package包/类
public static void main(String args[]) {
Player player;
// This is little trick simply to keep
// the application running indefinitely.
JFrame f = new JFrame();
if( args.length != 1 ) {
System.err.println("Usage:");
System.err.println("java ejmf.examples.basics.JMFAudioLoop <Media>");
return;
}
String media = args[0];
try {
URL url = new URL("file:///" + new File(media).getCanonicalPath());
player = Manager.createPlayer(url);
player.addControllerListener(new LoopListener());
player.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
示例2: main
import javax.media.Player; //导入方法依赖的package包/类
public static void main(String args[]) {
JPanel playerPanel;
Player player;
if( args.length != 1 ) {
System.err.println("Usage:");
System.err.println("java ejmf.examples.basics.JMFVideoToo <Media>");
return;
}
String media = args[0];
JFrame f = new JFrame(media);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
});
playerPanel = new JPanel();
playerPanel.setLayout(new BorderLayout());
f.getContentPane().add(playerPanel);
f.pack();
f.setVisible(true);
try {
URL url = new URL("file:///" + new File(media).getCanonicalPath());
player = Manager.createPlayer(url);
player.addControllerListener(new VideoTooListener(playerPanel));
player.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
示例3: installPlayer
import javax.media.Player; //导入方法依赖的package包/类
/** In response to TrackModelEvent, add a Player.
* initPlayer is called to bring Player to prefetched
* state. If a ViewingPanel exists, the Player screen
* is displayed. Newly added Player adopts TimeBase
* of current master Player.
*
* @param tm TrackModel to which Player is being added.
* @param index which track is getting a new Player
* @see javax.media.TimeBase
* @see ejmf.toolkit.multiplayer.TrackModelAssignEvent
* @see ejmf.toolkit.multiplayer.TrackModel
* @see ejmf.toolkit.gui.ViewingPanel
* @see ejmf.toolkit.gui.ViewScreen
*
*/
private void installPlayer(TrackModel tm, int index) {
Debug.printObject("enter installPlayer : " + index);
Track track = tracks.getTrack(index);
Player player = track.getPlayer();
player.addControllerListener(this);
synchronized (this) {
nActiveTracks++;
}
if (viewingPanel != null)
viewingPanel.addScreen(track.getMediaLocator().toString(),
player,
ViewingPanel.DISPLAY_BOTH);
Debug.printObject("exit installPlayer : " + index);
}
示例4: createPlayer
import javax.media.Player; //导入方法依赖的package包/类
private static synchronized Player createPlayer(String mediaUri) {
try {
URL url = replaceJarUrlWithFileUrl(ResourceManager.getResource(mediaUri), mediaUri);
MediaLocator locator = new MediaLocator(url);
final Player mediaPlayer = Manager.createRealizedPlayer(locator);
// add a listener to put us in an infinite loop
mediaPlayer.addControllerListener(new ControllerListener() {
public void controllerUpdate(ControllerEvent evt) {
if(evt instanceof EndOfMediaEvent) {
mediaPlayer.setMediaTime(new Time(0));
mediaPlayer.start();
}
}
});
return mediaPlayer;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例5: main
import javax.media.Player; //导入方法依赖的package包/类
public static void main(String args[]) {
JPanel playerPanel;
Player player;
if( args.length != 1 ) {
System.err.println("Usage:");
System.err.println("java ejmf.examples.basics.JMFManualControl <Media>");
return;
}
String media = args[0];
JFrame f = new JFrame(media);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
});
playerPanel = new JPanel();
playerPanel.setLayout(new BorderLayout());
f.getContentPane().add(playerPanel);
f.pack();
f.setVisible(true);
try {
URL url = new URL("file:///" + new File(media).getCanonicalPath());
player = Manager.createPlayer(url);
player.addControllerListener(new AudioControlListener(playerPanel));
player.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
示例6: init
import javax.media.Player; //导入方法依赖的package包/类
/**
* This method is run when PlayerDriver is an applet.
*/
public void init() {
Player player;
String media;
JPanel playerPanel;
playerPanel = new JPanel();
playerPanel.setLayout(new BorderLayout());
add(playerPanel);
// Get the media filename
if((media = getParameter("MEDIA")) == null) {
System.err.println("Invalid MEDIA file parameter");
return;
}
try {
String name = new File(media).getCanonicalPath();
URL url = new URL("file:///" + name);
player = Manager.createPlayer(url);
player.addControllerListener(new VideoTooListener(playerPanel));
player.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
示例7: AbstractControls
import javax.media.Player; //导入方法依赖的package包/类
protected AbstractControls(Player player) {
if (player.getState() < Controller.Realized)
throw new NotRealizedError("Player must be realized");
this.player = player;
makeControls();
setControlsPlayer(player);
player.addControllerListener(this);
}
示例8: StateHelper
import javax.media.Player; //导入方法依赖的package包/类
public StateHelper(Player p) {
player = p;
p.addControllerListener(this);
}