• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Player类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.media.Player的典型用法代码示例。如果您正苦于以下问题:Java Player类的具体用法?Java Player怎么用?Java Player使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Player类属于javax.media包,在下文中一共展示了Player类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: JMFrame

import javax.media.Player; //导入依赖的package包/类
public JMFrame(Player player, String title) {
super(title, true, true, true, true);
getContentPane().setLayout( new BorderLayout() );
setSize(320, 10);
setLocation(50, 50);
setVisible(true);
mplayer = player;
mplayer.addControllerListener((ControllerListener) this);
mplayer.realize();
addInternalFrameListener( new InternalFrameAdapter() {
    public void internalFrameClosing(InternalFrameEvent ife) {
	mplayer.close();
    }
} );
	    
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:17,代码来源:MDIApp.java


示例2: 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.JMFAudioOnly <Media>");
           return;
       }

       String media = args[0];
try {
    URL url = new URL("file:///" +  new File(media).getCanonicalPath());
    player = Manager.createPlayer(url);

           player.start();
       }
catch (Exception e) {
    e.printStackTrace();
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:24,代码来源:JMFAudioOnly.java


示例3: 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();
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:26,代码来源:JMFAudioLoop.java


示例4: 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();
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:38,代码来源:JMFVideoToo.java


示例5: main

import javax.media.Player; //导入依赖的package包/类
public static void main(String args[]) {
       if( args.length == 0 ) {
           System.out.println("Specify at least one media URL/file");
 	    return;
       }
      
       Vector v = new Vector();

       //  Create a Vector of Players
       for(int i = 0; i < args.length; i++) {
           try {
               Player p = Manager.createPlayer(
                   Utility.appArgToMediaLocator(args[i]) );
               new StateWaiter(p).blockingRealize();
               v.addElement(p);
           } catch(Exception e) {
               System.out.println( "Could not create Player for " + args[i]);
	e.printStackTrace();
           }
       }

       //  Choose a Master
       players = new Player[ v.size() ];
       v.copyInto(players);
new XSync(players);
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:27,代码来源:XSync.java


示例6: blockingPrefetch

import javax.media.Player; //导入依赖的package包/类
/**
*  A wrapper around StateWaiter's <tt>blockingPrefetch<tt>
       * that stops the Player if necessary before testing state.     
       * If Controller state is less than <tt>Prefetched</tt>, then
    	* Controller is moved to this state.
       * 
       * This method performs a slight optimization by checking whether
       * Controller is already in the <tt>Prefetched</tt> state.
* If so, return is immediate.
       *
       * @param player A javax.media.Player
  	@ @see ejmf.toolkit.util.StateWaiter
     	*/
   private boolean blockingPrefetch(Player player) {

int state = player.getState();
	if (state == Controller.Prefetched) {
    return true;
}

if (state == Controller.Started) {
    player.stop();
}

if (state < Controller.Prefetched) {
    StateWaiter sw = new StateWaiter(player);
           return sw.blockingPrefetch();
}
return true;
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:31,代码来源:MultiPlayerControl.java


示例7: MultiPlayer

import javax.media.Player; //导入依赖的package包/类
/** 
    * Create a MultiPlayer from an array of media file names.
* @param mediaFiles An array of media file names		
* @param mpc A MultiPlayerControl strategy. 
    */

   public MultiPlayer(String[] mediaFiles, MultiPlayerControl mpc) {
tracks = new TrackList(mediaFiles.length);
for (int i = 0; i < mediaFiles.length; i++) {
    try {
        String path = new File(mediaFiles[i]).getCanonicalPath();
        MediaLocator ml = Utility.appArgToMediaLocator(path);
        Player player = Manager.createPlayer(ml);
        tracks.addElement(new Track(i, ml, player));
    } catch (Exception e) {
	System.err.println(
	    "Unable to create Player from " + mediaFiles[i]);
	continue;
	    }
}
nActiveTracks = addAsListener(tracks);
setControlStrategy(mpc);
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:24,代码来源:MultiPlayer.java


示例8: displayPlayers

import javax.media.Player; //导入依赖的package包/类
/** Display all Player ViewScreens
    * 
    */
    public void displayPlayers() {
if (viewingPanel == null)
    return;

       for (int i = 0; i < tracks.getNumberOfTracks(); i++) {
    Track track = tracks.getTrack(i);
    if (track.isAvailable())
	continue;
    Player player = track.getPlayer();
    String path = track.getMediaLocator().toString();
    viewingPanel.addScreen(new File(path).getName(), 
			player, 
			ViewingPanel.DISPLAY_BOTH);
}
    }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:19,代码来源:MultiPlayer.java


示例9: query

import javax.media.Player; //导入依赖的package包/类
/**
     * A debugging hook for dumping contents of each Track
     * to the file.dbg.out.
     */
   public void query() {
for (int i = 0; i < tracks.getNumberOfTracks(); i++) {
    Track track = tracks.getTrack(i);
    Player p = track.getPlayer();

    System.out.println("++++++++++++++++++++");

    if (track.isAvailable()) {
	System.out.println("Track " + i +  " not assigned");
 	continue;
           }
    System.out.println("player = " + track.getMediaLocator().toString());
           System.out.println("state = " + Utility.stateToString(p.getState()));
           System.out.println("media time = " + p.getMediaTime().getSeconds());
           System.out.println("stop time = " + p.getStopTime().getSeconds());
           System.out.println("duration = " + p.getDuration().getSeconds());
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:23,代码来源:MultiPlayer.java


示例10: 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);
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:31,代码来源:MultiPlayer.java


示例11: forceRealized

import javax.media.Player; //导入依赖的package包/类
private void forceRealized(TrackList tracks) {
for (int i = 0; i < tracks.getNumberOfTracks(); i++) {
    Track track = tracks.getTrack(i);
    if (track.isAssigned()) {
        Player player = track.getPlayer();
        int state = player.getState();
        if (state == Controller.Started) {
	    player.stop();
	}

        if (state > Controller.Realized) {
	    player.deallocate();
	}
    }
}
    }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:17,代码来源:TimerMultiPlayerControl.java


示例12: NPlayerPanel

import javax.media.Player; //导入依赖的package包/类
/** 
* Create an NPlayerPanel from a MultiPlayer.
* In this case, Players are already constructed.
* Players are moved to prefetch state.
*/
   public NPlayerPanel(MultiPlayer mp) {
tracks = mp.getTrackList();
Vector	v 	= new Vector();
       for (int i = 0; i < tracks.getNumberOfTracks(); i++) {
    Track track = tracks.getTrack(i);
    if (track.isAssigned()) {
	v.addElement(track.getPlayer());
    }
       }

players = new Player[v.size()];
v.copyInto(players);

setLayout(createLayout(players.length));
for (int i = 0; i < players.length; i++) {
    StateWaiter waiter = new StateWaiter(players[i]);
    waiter.blockingRealize();
    displayPlayer(players[i], tracks.getTrack(i).getMediaLocator());
    waiter.blockingPrefetch();
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:27,代码来源:NPlayerPanel.java


示例13: createAndDisplayPlayers

import javax.media.Player; //导入依赖的package包/类
private void createAndDisplayPlayers(MediaLocator[] mls) 
		throws NoPlayerException, IOException {
StateWaiter	waiter;

setLayout(createLayout(mls.length));

players = new Player[mls.length];
for (int i = 0; i < mls.length; i++) {
    players[i] = Manager.createPlayer(mls[i]);
    waiter = new StateWaiter(players[i]);
    waiter.blockingRealize();

    displayPlayer(players[i], mls[i]);

    waiter.blockingPrefetch();
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:18,代码来源:NPlayerPanel.java


示例14: timeDragged

import javax.media.Player; //导入依赖的package包/类
private void timeDragged(int x) {
if (player == null)
    return;
// Determine the requested media time based on duration of the file
// and position of the mouse in the control panel.
long dura = player.getDuration().getNanoseconds();
if (dura < 0 || dura > 3 * 3600 * 1000000000L)
    return;
long nano = (long) ((float) (x - COMPONENTS[MEDIATIME][0]) /
		    (COMPONENTS[MEDIATIME][2] -
		     COMPONENTS[MEDIATIME][0] + 1) * dura);
if (nano < 0) nano = 0;
if (nano > dura) nano = dura;
// Set the media time
player.setMediaTime(new Time(nano));
if (player.getTargetState() < Player.Started)
    player.prefetch();
repaint();
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:20,代码来源:MainWindow.java


示例15: 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();
    }

    if (ce instanceof ControllerErrorEvent) {
        p.removeControllerListener(this);
        LOGGER.severe("Receiver internal error: " + ce);
    }

}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:AudioReceiver.java


示例16: 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());
        }

    }
 
开发者ID:gabrielbiga,项目名称:Hook-FreshMeat,代码行数:25,代码来源:MediaPlayer.java


示例17: 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();
    }

    if (ce instanceof ControllerErrorEvent) {
        p.removeControllerListener(this);
        LOGGER.error("Receiver internal error: " + ce);
    }

}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:22,代码来源:AudioReceiver.java


示例18: realize

import javax.media.Player; //导入依赖的package包/类
public void realize(){
    if(!useAudioBuffer){
        try{
            if(midi){
                if(sequencer==null)
                    sequencer=MidiSystem.getSequencer();
            }
            else{
                if(player==null && dataSource!=null){
                    player=javax.media.Manager.createPlayer(dataSource);
                    if(player!=null) player.addControllerListener(this);
                }
                if(player!=null && player.getState()<Player.Realized)
                    player.realize();
            }
        } catch(Exception e){
            System.err.println("Error realizing media \""+mc.mediaFileName+"\"\n"+e);
        }
    }
}
 
开发者ID:projectestac,项目名称:jclic,代码行数:21,代码来源:JMFActiveMediaPlayer.java


示例19: 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;
    }
}
 
开发者ID:humphrej,项目名称:flexdock,代码行数:23,代码来源:MediaPanel.java


示例20: controllerUpdate

import javax.media.Player; //导入依赖的package包/类
public void controllerUpdate(ControllerEvent event) {
    Player p = (Player) event.getSourceController();
    if (event instanceof EndOfMediaEvent) {
    	    p.setMediaTime(new Time(0));
           }
    else if (event instanceof RealizeCompleteEvent) {
	cpc = p.getControlPanelComponent();
	if (cpc != null)
  	    SwingUtilities.invokeLater(new AddComponentsThread(cpc));
    }
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:12,代码来源:AudioControlListener.java



注:本文中的javax.media.Player类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PopupMenuUI类代码示例发布时间:2022-05-21
下一篇:
Java UsernamePasswordAuthentication类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap